Converting Bulk Text to Hyperlinks in Excel - vba

I am using Excel 2010. I have a column (A), for example that has about 500 numbers, all different. The number in each cell is slightly different. I want to turn them into hyperlinks in bulk(that's easy) if you have the same URL. The twist is that they all have different URLs BUT the URL are not that much different. They are the "same" URLs but the number in the cell is inserted at the end of the URL and that's a specific page.
EXAMPLE.
The first 3 rows (A1, A2, A3) are the numbers (977, 981, 961)
The URLs would show as PleaseHelp.com/index=977 , PleaseHelp.com/index=981, PleaseHelp.com/index=961
I want to put the hyperlink PleaseHelp.com/index="(A1, A2, A3)" and automatically insert what ever is in Row 1 and automatically insert the number and make it a hyperlink.
I know that I will have to use VBA to code but its tough.

A really easy way would be
B1 = HYPERLINK(CONCATENATE("http://www.something.com/index=",A1))
or
B1 = HYPERLINK("http://something.com/index="&A1)
(thanks Siphor)
then you could just fill that down.

Related

LibreOffice Calc: how to highlight the maximum value of ranges of cells at once?

I would like to highlight the maximum value for each group of cells using conditional formatting, and applying it at once.
In order to explain myself better, the file is something like this:
(But the real content has more than 1500 of these).
For each range in each column, I want to highlight the maximum value. So, for the range A1:A11, the cells A2, A5, A7 and A10 should be with a different format. The same for the range A18:A28, where A26 and A28 should be different, and so on for B, and C, etc.
I have tried selecting A1:I28 and apply conditional format where cell is equals to max(a1:a11) apply a good format, but it doesn't work well. It think I don't how to use the references in the sheet in order to be considered in a right way.
Any ideas?
AFAIK you can't do this "at once", thus in a single step. To get this working with a spreadsheet layout as in your example, you'll have to define the conditional formatting for each "dataset" separately (it would be easier if the spreadsheet wouldn't contain two "rows" (1st: 1-11; 2nd: 18-28) on the same sheet). With dataset, i mean the distinctive ranges A1:A11, B1:B11, ... A18:A28, B18:B28 and so on.
To be more precise: you need to define the conditional formatting rule for the first dataset of its row (in your example: A1:A11 and A18:A28, respectively), then you can apply it to the other datasets using format pasting.
To do so:
define the conditional formatting for range A1:A11 with formula A1=MAX(A$1:A$11). Notice the dollar signs - without them LO will compare A2 to MAX(A2:A12), A3 to MAX(A3:A13) and so on. The dollar signs make sure that every cell in A1:A11 will be compared to exactly that range only.
Select A1:A11, copy it;
Select B1:B11 and paste just the formatting, using the "Paste Special" functionality (Menu Edit -> Paste Special... or SHIFT+CTRL+V, select Format only in the Paste Special dialogue).
Repeat step 3 for C1:C11, D1:D11 and so on till I1:I11;
Repeat step 1 and 2 for A:18:A28 (formula should be A18=MAX(A$18:A$28));
Repeat step 3 for B18:B28 and so on.
If you try to paste the formatting to more than one column, LO won't handle the target range as entity but will define the formatting for each cell, thus it will define a conditional format for B1 with formula B1=MAX(B$1:B$11), B2 with B2=MAX(B$2:B$12) and so on. It's vital to have only one conditional format definition for each separate range, thus for A1:A11, B1:B11 and so on. You can control how LO had handled your modifications by checking the resulting conditional format definitions in Menu Format -> Conditional Formatting -> Manage....

Lookup function in multiple sheets data

I have multiple sheets of data and I want to make it in one sheet (All of them are in the same workbook). Link to the excel file.
I tried to use Hlookup function in excel file, something like below:
=HLOOKUP("University",Sheet1!$A$1:$G$2, 2, FALSE).
But, since I have more than 100 sheets of data, I want to find a way to drag the function and auto generate the function below the 2nd row. I have tried to use indirect function by setting a reference column in front as below but cannot deal with it.
=HLOOKUP("University", 'INDIRECT(A3)'!$A$1:$G$2, 2, FALSE)
My next option is VB code. But, I am new to VB. Anybody can help on it?
Place your individual sheet names in column H of the Summary sheet and the row number in column I (as helper columns) and write this formula in cell A2 of the summary sheet.
=IFERROR(HLOOKUP(A$1,INDIRECT($H2&"!A1:G"&$I2),$I2,0),)
and drag to column F and down for as many sheet rows combos you have. I used 10 rows but you can obviously make it longer or shorter as neeed.
When you are done you can filter on 0 in column A and remove any lines with no data.
If your sheet names have spaces in them, you'll need to adjust the INDIRECT formula to this:
INDIRECT("'"&$H2&"'!A1:G"&$I2)
best way would be "defined names" + INDIRECT + HLOOKUP (or LOOKUP) like:
defined names
name: SList
formula: =MID(TRANSPOSE(GET.WORKBOOK(1))&T(NOW()),FIND("]",TRANSPOSE(GET.WORKBOOK(1))&T(NOW()))+1,255)
formula in cells: (this in A2 then simply autofill to G2 and thenn everything down) (you'll get a row with 0's between the sheets, which can be filtered out or deleted later (copy/paste values))
=IFERROR(HLOOKUP(A$1,INDIRECT("'"&INDEX(SList,COUNTIF($A$1:$A1,0)+2)&"'!$A:$G"),$H2,0),"")
Set H2 to 2 and for H3: (autofill down from H3)
=MAX(($H2+1)*($A2>0),2)
works perfectly for me LINK
No manual typing of sheetnames or something like that (only Column H:H as helper). Youll get rows's with 0's every time a new sheet is selected which can be filtered out. (or if you copy/paste values also can be deleted)
the +2 at ...st,COUNTIF($A$1:$A1,0)+2)&... simply tells to start with sheet 2 (if summary is the first). You may change it to +1 if you want to lookup starting with the first sheet.
Assuming you already have all 100+ sheet names typed out in column A, this will work whether or not you have spaces in the sheet names:
=HLOOKUP("University", OFFSET(INDIRECT(ADDRESS(1,1,1,1,A2)),0,0,2,7),2,FALSE)

Excel SpecialCells(xlCellTypeBlanks) fails with merged cells

Excel SpecialCells(xlCellTypeBlank) includes all cells in a merged range, regardless of whether they are blank. I consider this to be a bug, and I desperately need a workaround. Steps to duplicate:
(1) Create a worksheet with some text in cells A1 and B3. Now activesheet.usedrange.cells.count = 6 and
activesheet.usedrange.specialcells(xlcelltypeblanks).cells.count = 4
These values are as expected.
(2) Now merge cells A1:A2, and
activesheet.usedrange.cells.count = 6 and
activesheet.usedrange.specialcells(xlcelltypeblanks).cells.count = 5
Both A1 and A2 are now considered blank.
I need to find a way to select just cells A3, B1, and B2 in this case. I'm actually doing this using .NET Excel Interop, so I do not want to have to actually retrieve the cell value as a part of the test, since this is a huge performance penalty in Excel Interop; so I'm restricted to an internal cell selection function such as SpecialCells.
I got this to work by selecting smaller ranges at various places in the code, usually just before doing any cell merging. I consider this to be a workaround, not really a solution. Thanks to those who commented - you helped inspire this workaround.

Loop and Grab box to the right

I'm currently working on a project that requires loops which I'm not to sure how to go about doing.. I have the information in blocks so for each client I have a bunch of information so for instance I will have A1 say Name: and B1: say Bob,
Then A17 will be again Name: B17: George
This keeps going for approximately 1000 rows. I need to find a way to circulate through all of the material and grab all the names and place them in a column following each other.
I guess I'm looking for a loop that finds name gives me the value to the right, and then it keeps doing that all the way down.
Anyone have any ideas?
Very simple...........say your names are stored in column B in cells B1, B17, B33, B49, ...basically 16 rows apart...Then in cell C1 enter:
=INDIRECT("B" & 16*ROW()-15)
and copy down. This is good for evenly spaced records
EDIT#1:
Since the records are not evenly spaced..........in C2 enter the following array formula:
=INDEX($B$1:$B$1000,SMALL(IF($A$1:$A$1000="Name",ROW($A$1:$A$1000)),ROW()-ROW($C$2)+1))
and copy down.
This is an Array Formula . Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
Something like:
Adopted from simocos post
in C1 enter this formula : (with Ctrl+ shift + Enter)
= IFERROR( INDEX($B$1:$B$1000; AGGREGATE(15;6;(ROW($B$1:$B$1000)-ROW($B$1)+1)/($B$1:$B$1000<>"");ROWS(C$1:C1)));"")
then copy the cell down
(the formula is not from me. I use it in one of my workbooks, and adapted it)

Linking cells in excel with a specific format

I am trying to link cells in excel on two different work sheets.
I am using the formula eg: cell1 = cell2 + cell3. The numbers that I have in cell2 and cell3 are in format of 100% (1) and 50% (2). I just want to add numbers 1 and 2 so that my cell1 will have number 3.
Is it possible to do without changing the cell formats?
Thanks a lot.
If you don't care about the percentages, just copy your column with the percentages and change the format of that column to value and in sheet 2, do addition on that column instead.
Unfortunately when a cell has a format of percentage and a user enters a number, it is converted into what it means given the context of the format. It's not like what is being displayed is wildly different than what is 'hidden' inside the cell. When you reformat a cell, that data is reformatted as well, so 50% becomes .5 even if you had originally entered 50 in the cell before changing it's format. Format is more than just 'display format' so maybe that's where the confusion is.
If you want to add the cells in the percentage row and not bother with reformatting the formula cell you can cheat and treat it as a string to get rid of that %. You could do =Left(A2+A3, Len(A2+A3)) that will give you the 1.5 answer without having to format te cell.
Not sure i understood your question but i'll give some elements:
formula and formats are separated in Excel, thus, you can set a formula in A1, say =A2+A3 but displays the value the way you wish
for instance, if A2 contains 100% and A3 contains 50%, then the result in A1 is worth 1.5
you can set the format of A1 the way you wish (Right-clic > Format cells > Number tab), for instance, decimal, the cell will then display 1.5 but if you choose percentage, the cell will then display 150%
Please elaborate your question if needed.
[EDIT] New answer thanks to your comment:
If i understand well, you want to sum up the values between brackets in your cell (whatever is before, event percentages in your case).
Then, you can try this in cell A3:
=MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1 )+MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1 )