Having some minor problems with some code, the code below when input a date into a input box, picks out the whole line of data within a workbook and copies it over into a other.
What I require is that currently when the data is copied pastes over to cell A2, I want it to start at M2 instead and move therefore in column M, also there seems to be a problem with the loop, it only picks out one single line of data when a date is inputted when I know there are around another 100 lines to be copied, don't think its lopping through all the data.
Sub Update_Button()
Dim x, y As Range, rThis As Long, rPrev As Long
x = InputBox("Enter Date of Update")
x = CDate(x)
ChDir "S:\Broker"
Workbooks.Open Filename:= _
"\\24\opsales\Broker\Total.xls"
With Workbooks("Records_File")
Set y = .Sheets("sheet1").Cells.Find(x)
rThis = y.Row
rPrev = rThis - 1
Do While (rPrev < rThis)
Windows("Summary 2005.xls").Activate
With .Sheets("Sheet1")
y.EntireRow.Copy .Cells(.[A1].CurrentRegion.Rows.Count + 1, 1)
End With
Set y = Cells.FindNext
rPrev = rThis
rThis = y.Row
Loop
End With
MsgBox ("Update Complete")
End Sub
What I require is that currently when the data is copied pastes over to cell A2, I want it to start at M2 instead and move therefore in column M, also there seems to be a problem with the loop, it only picks out one single line of data when a date is inputted when I know there are around another 100 lines to be copied, don't think its lopping through all the data.
Sub Update_Button()
Dim x, y As Range, rThis As Long, rPrev As Long
x = InputBox("Enter Date of Update")
x = CDate(x)
ChDir "S:\Broker"
Workbooks.Open Filename:= _
"\\24\opsales\Broker\Total.xls"
With Workbooks("Records_File")
Set y = .Sheets("sheet1").Cells.Find(x)
rThis = y.Row
rPrev = rThis - 1
Do While (rPrev < rThis)
Windows("Summary 2005.xls").Activate
With .Sheets("Sheet1")
y.EntireRow.Copy .Cells(.[A1].CurrentRegion.Rows.Count + 1, 1)
End With
Set y = Cells.FindNext
rPrev = rThis
rThis = y.Row
Loop
End With
MsgBox ("Update Complete")
End Sub
Code:
Hope you can help