Retrieving information to be put into form

mbelleng

New Member
Joined
Sep 21, 2010
Messages
1
Hello,
I am a novice in terms of Excel and VB and am trying to make a macro retrieve information from a particular line in one worksheet and insert it into the appropriate cells in the form worksheet. Currently I am using the
following and it works but after having used it for 234 lines, you can imagine that the sub has become too long to run:

RespLine = InputBox("Please enter the line number you would like to retrieve:")
If RespLine = "" Then Exit Sub

RespLine = Int(RespLine)
If RespLine = 1 Then
MsgBox "Line number must be greater than 1", vbOKOnly
Sheets("New Hire").Select
Exit Sub
End If

ActiveWindow.WindowState = xlMinimized
Sheets("DATABASE FOR MERGE").Select
Cells(RespLine, 1).Select
Selection.Copy
Sheets("New Hire").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("DATABASE FOR MERGE").Select
Cells(RespLine, 2).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("New Hire").Select
Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Most of the information to be put back is in continuous cells, such as lines 24 to 36 go into cells B15 to B27. Is there a more efficient way to do this retrieve?

Please help! Thank you,
 

Forum statistics

Threads
1,081,543
Messages
5,359,431
Members
400,527
Latest member
pro2go

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top