Hi, this is my first post, so here we go...
for my Statistics coursework, I am required to find info about a variety of people from a large table of data in excel. I have crafted a series of HLOOKUP formula which return all the relevant data from entry of a randomly generated reference number. the issue comes when I need to copy the results from the formula to a separate table. I am currently doing this manually with the paste special - values function but for 35 different numbers, this is taking an age.I have created a Macro to do this for me, but I am having troubles getting VB to return to the appropriate cell to paste the data again. here is my code. note this is my FIRS EVER VB code, or code of any type for that matter, and it is compiled from the internet's worth of utterly useless articles I have been able to find (can it seriously be that I am the only one who wants to do this? someone must have come before...) anyway, here goes...
for further clarification, I will post a screenshot showing what I want done. apparently, it is the line "Cells(StartRow, StartCol + 1).Select" that seems to be the problem, but as I said, I have NO experience of VB so I'm not sure how to fix the problem, which, according to Excel, is "Application- or User-defined" and I have no Idea what that means. I need this fixed swiftly so I can meet my deadline.
anyway, thanks in advance, Bye.
for my Statistics coursework, I am required to find info about a variety of people from a large table of data in excel. I have crafted a series of HLOOKUP formula which return all the relevant data from entry of a randomly generated reference number. the issue comes when I need to copy the results from the formula to a separate table. I am currently doing this manually with the paste special - values function but for 35 different numbers, this is taking an age.I have created a Macro to do this for me, but I am having troubles getting VB to return to the appropriate cell to paste the data again. here is my code. note this is my FIRS EVER VB code, or code of any type for that matter, and it is compiled from the internet's worth of utterly useless articles I have been able to find (can it seriously be that I am the only one who wants to do this? someone must have come before...) anyway, here goes...
Code:
Sub Macro5()
'
' Macro5 Macro
' Macro recorded 28/01/2010 by Joe
'
' Keyboard Shortcut: Ctrl+l
'
Dim StartCol As Integer
Dim StartRow As Integer
StartRow = ActiveRow
StartCol = ActiveColumn
Selection.Copy
Range("AF13").Select
ActiveSheet.Paste
Range("AG13", "AL13").Select
Selection.Copy
Cells(StartRow, StartCol + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
anyway, thanks in advance, Bye.