Combining Text and Hyperlink Into Text that is Hyperlinked - vba

I have text in column A and URLs in column B.
I want the merged A&B shown in column C.
Example:
Column A | Column B | Column C
Product 1 | google_dot_com | Product 1 (with hyperlink to url)
Product 2 | yahoo_dot_com | Product 2 (with hyperlink to url)
Product 3 | stackoverflow_dot_com | Product 3 (with hyperlink to url)
Here is an image.
This is different from just referencing the cells and using the HYPERLINK(A1,B1) and then copying it down column C.
Here is a small test file I created that you can download if my above example wasn't clear enough. http://www.filedropper.com/stacker-help
Using Microsoft Office Professional Plus 2013, Windows 7

=HYPERLINK(B2,A2) should work as per your image requirement. Please check
store the link(column B) in text format

Use the CONCATENATE-Funktion in Excel, e.g.=CONCATENATE(A1;B1).
If you need the square bracets just add them in eg.g =CONCATENATE(A1;"[";B1;"]").
The function-names in Excel depend on your language, you might have to use a translated version (in Germany 'VERKETTEN', other languages see http://en.excel-translator.de/CONCATENATE/).
And it gets better: in german you need ";" to seperate the parameters, in english it's a ",".
Translating funktion-names like in Excel should be considered a crime.

I have found the answer I was looking for, here is the VBA code I used.
Sub MergingCells()
For i = 2 To Range("a1").End(xlDown).Row
Sheets("sheet1").Hyperlinks.Add anchor:=Cells(i, 3), Address:="http://" & Cells(i, 2).Value, TextToDisplay:=Cells(i, 1).Value
Next i
End Sub

Related

How to Embed Excel Formula in SSRS Report [duplicate]

I have an ssrs report that sums a column for a total, like so:
=Sum(CDEC(Fields!Month01Balance.Value))
Now, when exporting to excel this does not export as a formula. I was told there is a way to do it using the ReportFields collection, however I cannot get that to work. Does anyone know of a way I can get a total column to export a formula to excel? I don't know how many rows there will be so I cannot manually reference each ReportField text box.
Thanks for any pointers here!
You must replace the VALUE of the cell with text representing the formula, but the formula must be preceded by a single apostrophe: e.g.,
A | B | C
2 | 4 | 6
Becomes:
A | B | C
2 | 4 | '=A1+B1
When you export the report to Excel, replace all the single apostrophes with [nothing]. The formulas should now run.
Suggestion: Create a new boolean report parameter called "Show_Formulas." Then, write an expression for field C: =IIF(Parameters!ShowFormulas.Value,"'=A" & RowNumber("myQuery") & "+B" & RowNumber("myQuery"),Fields!C.Value)
This way, the enduser can either see the values in the report, or re-run the report showing the formulas for export.

Excel vba code to copy names found in multiple worksheets and count how many times they appear

I need some help writing some VBA code.
Basically I have one spreadsheet with 4 worksheets (CLIENT1, CLIENT2, CLIENT3, CLIENT4)
Each worksheet contains a column called CONTACT.
This CONTACT column contains a person name
The CONTACT column can be in a different position in each worksheet ie the CONTACT column in CLIENT1 is in Column D whereas it appears in column E in CLIENT2
I would like some help writing some code that will create a new Worksheet called SUMMARY.
The SUMMARY worksheet would contain in Column A a list of all the names found in the CONTACT column and in Column B it would count the number of times that persons name was found.
So the SUMMARY worksheet would end up looking something like this.
A B
1 John Smith 4
2 Brad Black 2
3 Gary Soth 1
4 Bob Brown 6
5 Sam Drow 2
Hope this makes sense and thanks for your help
Andy
Note : I am just playing with Excel and not using VBA but think you can achieve it without using VBA also.
You can use COUNTIF and solve your problem.
I will show you step by step. I cant attach excel here so adding images. If you wish to have excel which i prepared then just give me your email, I will send it.
This is summary which I got by using the formula (you can see that highlighted :
Client Name column can get value from the sheet where you can combine all your unique client names and use that as base.
Check Client1, 2, 3 & 4 sheets.
Hope this may help you.
Just found that in Excel you can use the Remove Duplicates function to remove all unwanted names. I can then use the count function across all 4 worksheets to get the required information.
Thanks
Andy

Using Indirect within Advanced Filter

Hello Stack Overflow Community,
I am currently creating an automated report that imports two or more CSV files from a given folder. The unique identifier that I need to use for a VLOOKUP is in an obscure column, so what I needed to do was Cut and Insert the found column onto Column 'A'. Example Below.
With wksRawData
'~~> Move Process ID Column to Column 'A' for VLOOKUP
.Columns(WorksheetFunction.Match("pid", .Range("1:1"), 0)).Cut
.Columns(1).Insert Shift:=xlToLeft
'~~> Remove Additional Headers
.Cells.RemoveDuplicates Columns:=Array(1)
End With
This part works great, but I have a formula in another worksheet that is supposed to reference $A2 and it gets changed to $B2. The reason why it should reference $A2 is because it is being used in an Advanced Filter Formula, and is the very first data point. Formula Below.
=IF(COUNTIF($C:$C, 'Raw Data'!$A2)=0, TRUE, FALSE)
When used in tandem with the other Advanced Filter columns this formula will whitelist any manually added unique identifiers. Example Below.
PID Whitelist | | user | proc | PID Whitelisted?
---------------+------+--------+----------------+------------------
182 | | root | | < FORMULA_ABOVE >
11 | | test | | < FORMULA_ABOVE >
1776 | | | Jazzy Rabbit | < FORMULA_ABOVE >
I've attempted to use INDIRECT, ADDRESS, and INDEX in the place of 'Raw Data'!$A2, but since they reference an absolute destination the Advanced Filter always uses the very first unique identifier value; instead of the current row's value.
Thank you in advance for your time, and I really appreciate any assistance provided!
NOX
I would suggest simply rewriting the formula immediately after the VBA column insert. Example (with improved (?) formula:
With wksRawData
'~~> Move Process ID Column to Column 'A' for VLOOKUP
.Columns(WorksheetFunction.Match("pid", .Range("1:1"), 0)).Cut
.Columns(1).Insert Shift:=xlToLeft
'~~> Remove Additional Headers
.Cells.RemoveDuplicates Columns:=Array(1)
End With
sheets("Some_Sheet").cells(x, y).formula = "=NOT(COUNTIF($C:$C, 'raw data'!$A2))"
'aslo one additional variant of the #Jeeped idea, without formulas
With wksRawData
.Columns(Range("1:1").Find("pid").Column).Cut
.Columns(1).Insert
.Cells.RemoveDuplicates Columns:=Array(1)
End With
Sheets("Some_Sheet").Cells(x, y).Value = _
WorksheetFunction.CountIf(Columns(3), Sheets("raw data").Cells(2, 1).Value)

VBA - Index / Match function with multiple criteria

I am facing an issue when trying to compile a multiple criteria Index/Match code in VBA. This might be simple - but i am fairly new to VBA and nothing i have found around here worked.
Example:
I have a large amount of data in a specified range: Sheets("CustomerAccounts").Range(CustomerSheetRange)) - I need VBA to return data from column titled "Values" by checking three criteria: Customer = X, Type = External, OriginCountry = UAE (columns are not adjacent in the original spreadsheet)
The criteria are stored in separate variables set by user of the macro beforehand.
Customer | Type | Origin | Destination | Values
X | Internal | UAE | SA | Value 1
Y | Internal | UAE | SA | Value 2
X | External | UAE | SA | Value 3
X | External | ZA | UAE | Value 4
At the moment i have the following (quite bulky) code which finds the value using one criteria - OriginCountry variable.
The code searches for it in a pre-specified column - OriginCountryColumn.
ResultString = Application.Index(Sheets("CustomerAccounts").Range(CustomerSheetRange), Application.Match(OriginCountry, Sheets("CustomerAccounts").Range(OriginCountryColumn), 0), Application.Match("Values", Sheets("CustomerAccounts").Range(TitleRowCust), 0))
I would like to modify the code to also match the Type and The customer.
Is it possible to expand the above Index/Matxh function - or should i use a different approach?
Any advice is appreciated.
You may walk through rows checking matches:
Dim row as Long
With Sheets("CustomerAccounts").Range(CustomerSheetRange))
For row = 2 To .Rows.Count 'Starts in 2 to ignore header!
If .Cells(row, costumerCol).Value Like costumerCriteria And .Cells(row, typeCol).Value Like typeCriteria And .Cells(row, originCol).Value Like originCriteria Then
'This is a match!
Debug.Print .Cells(row, valueCol)
End if
Next
End With
You must replace costumerCol, typeCol, originCol and valueCol with corresponding column number and costumerCriteria, typeCriteria and originCriteria with criteria specified.
If column indexes are also variable, make a search for them in first row before walking through rows.
First, format the range containing your data to a Table (See http://office.microsoft.com/en-001/excel-help/quick-start-create-an-excel-table-HA010359200.aspx on how to do that). Once done, use the following VBA code:
SomeCustomer = Range("...").Value
SomeType = Range("...").Value
SomeOrigin = Range("...").Value
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria=SomeCustomer
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria=SomeType
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria=SomeOrigin
Notes:
You might have to customize this macro for your specific needs
Name of table can be found/modified through Formulas>Name Manager
ActiveSheet might be modified to the actual sheet you are using

Generate Multiple page document from multiple line in excel

In my excel I have multiple line like this:
Name Age Tel
John 5 12345677
Peter 10 4547567
Mary 6 46u7687867
I am wondering How can I generate multiple document from excel to multiple invoice like this:
page1:
Certification of XXXXX
John Age 5
page2:
Certification of XXXXX
Peter Age 10
page3:
Certification of XXXXX
Mary Age 6
Thanks!
Assuming the above input & comments, the following code will do the job:
Sub ListPrinting()
Dim i As Long
i = 1
For i = 2 To ThisWorkbook.Sheets(1).Range("A1").CurrentRegion.Rows.Count
ThisWorkbook.Sheets("Invoice").Range("F40").Formula = ThisWorkbook.Sheets(1).Cells(i, 1).Formula
ThisWorkbook.Sheets("Invoice").Range("I38").Formula = ThisWorkbook.Sheets(1).Cells(i, 2).Formula
ThisWorkbook.Sheets("Invoice").Range("I9").Formula = ThisWorkbook.Sheets(1).Cells(i, 3).Formula
ThisWorkbook.Sheets("Invoice").PrintOut Copies:=1, ActivePrinter:="pdfFactory Pro on FPP4:" 'Specify your printer
Next i
MsgBox i - 2 & " invoice(s) printed."
End Sub
Please note:
You should specify the name of desired printer - use macro-recorder and just select it in the list of available printers on Print dialog.
The amount of records in list is practically unlimited... well, paper and ink / toner are not))) All of them will be printed starting row 2 and up to the last non-empty string found on the list sheet.
Test the code on 1-2 items to avoid paper loss)
Sample file is shared (code tested as well): https://www.dropbox.com/s/296e200496gd7gb/ListPrinting.xlsm
P.S. Perhaps you should reformat the Date field as you desire - it uses regional settings and therefore will be displayed for you differently.
For generating multiple page document lines from multiple line in excel you should flow
some steps and for knowing that you can visit http://fetchflow.com/support/question/How-do-I-create-a-new-purchase-order.html