stirlingmw1
Board Regular
- Joined
- Jun 17, 2016
- Messages
- 53
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Morning all
I have been trying for a couple of days now but seem to get the same results each time, please help.
I have a sheet "prepared" within my workbook with 2 separate ranges (A1:A50) and (A51:C100) that could contain data, I would like to loop through these ranges and if data is present in each row, copy certain cells of data from them onto another sheet "Uplifts" to make up a new row of data. So column B and C from the first set of rows would be copied to columns C and D of "Uplifts" and column C of the second range would be copied into column G of "Uplifts".
Each new row of data in the ranges would be copied into the next empty row in "Uplifts"
I have been trying to get this code to work, but it just adds the data over the top of the previous when it loops. Additionally this code would take the first 2 columns of data from another sheet which I do not want it to do, but i couldn't get the last row of each range, just the last row of all of the ranges combined.
TIA
Steve
I have been trying for a couple of days now but seem to get the same results each time, please help.
I have a sheet "prepared" within my workbook with 2 separate ranges (A1:A50) and (A51:C100) that could contain data, I would like to loop through these ranges and if data is present in each row, copy certain cells of data from them onto another sheet "Uplifts" to make up a new row of data. So column B and C from the first set of rows would be copied to columns C and D of "Uplifts" and column C of the second range would be copied into column G of "Uplifts".
Each new row of data in the ranges would be copied into the next empty row in "Uplifts"
I have been trying to get this code to work, but it just adds the data over the top of the previous when it loops. Additionally this code would take the first 2 columns of data from another sheet which I do not want it to do, but i couldn't get the last row of each range, just the last row of all of the ranges combined.
VBA Code:
Sub RecordUplift()
Dim WsC As Worksheet
Dim WsU As Worksheet
Dim WsP As Worksheet
Dim NeRowU As Long
Set WsC = Sheets("Copy")
Set WsU = Sheets("Uplifts")
Set WsP = Sheets("prepared")
NeRowU = WsU.Range("A" & Rows.Count).End(xlUp).Row + 1
RowCount = WsC.cells(Rows.Count, "A").End(xlUp).Row + 1
For i = 1 To RowCount
If Range("A1") <> "" Then
WsU.Range("C" & NeRowU).Value = WsP.Range("B" & i).Value
End If
Next i
End Sub
TIA
Steve