jolyji
New Member
- Joined
- May 27, 2020
- Messages
- 2
- Office Version
- 365
- 2019
- 2016
- 2013
- Platform
- Windows
- MacOS
I am trying to copy data from source WS to destination WS. I would like to know if I can use a loop to achieve the below result to avoid writing a long number of lines as shown below; Can someone help me to achieve this.
Sub Submit()
Dim sh As Worksheet
Dim sh1 As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Data_Input")
Set sh1 = ThisWorkbook.Sheets("Data_Source")
iRow = [Counta(Data_input!A:A)] + 1
sh.Range("A" & Last_Row + 1).Value = "=IF(B" & Last_Row + 1 & "="""","""",ROW()-1)"
With sh
.Cells(iRow, 2) = sh1.Range("C5").Value
.Cells(iRow, 3) = sh1.Range("C6").Value
.Cells(iRow, 4) = sh1.Range("C7").Value
.Cells(iRow, 5) = sh1.Range("C8").Value
.Cells(iRow, 6) = sh1.Range("C9").Value
.Cells(iRow, 7) = sh1.Range("C10").Value
.Cells(iRow, 8) = sh1.Range("d11").Value
.Cells(iRow, 9) = sh1.Range("G12").Value
.Cells(iRow, 10) = sh1.Range("G13").Value
Sub Submit()
Dim sh As Worksheet
Dim sh1 As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Data_Input")
Set sh1 = ThisWorkbook.Sheets("Data_Source")
iRow = [Counta(Data_input!A:A)] + 1
sh.Range("A" & Last_Row + 1).Value = "=IF(B" & Last_Row + 1 & "="""","""",ROW()-1)"
With sh
.Cells(iRow, 2) = sh1.Range("C5").Value
.Cells(iRow, 3) = sh1.Range("C6").Value
.Cells(iRow, 4) = sh1.Range("C7").Value
.Cells(iRow, 5) = sh1.Range("C8").Value
.Cells(iRow, 6) = sh1.Range("C9").Value
.Cells(iRow, 7) = sh1.Range("C10").Value
.Cells(iRow, 8) = sh1.Range("d11").Value
.Cells(iRow, 9) = sh1.Range("G12").Value
.Cells(iRow, 10) = sh1.Range("G13").Value