PDA

View Full Version : VBA Code to add to the below that will do a vlookup on certain columns that are merge



Spooky7
08-23-2015, 08:17 AM
I need some help to add a code to vlookup certain columns that are merged cells before or after making the worksheet copies. Thanks

Sub vbax_53547_CopySpecificSheetNTimes()

Dim x As Integer, numtimes As Integer

x = InputBox("Input the number of times to copy MySheet")

For numtimes = 1 To x
Sheets("MySheet").Copy After:=Sheets(Sheets.Count)
Next

End Sub

wanting to add this code to do the vlookup but getting errors once they are combined together?

Dim result As String
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Data")
result = Application.WorksheetFunction.VLookup(sheet.Range("A2"), sheet.Range("B2:D15")