It sounds like you need to find the first row with data in the Range("A8:A18")
, if that assumption is correct, then this is an example:
Sub foo()
Dim Source As Workbook
Dim wsTarget As Worksheet, wsSource As Worksheet
Dim sourceRange As Range
Dim targetLastRow As Long, sourceFirstRow As Long
Set Source = ThisWorkbook ' ### MODIFY AS NEEDED
Set wsSource = Source.Worksheets("Sheet1") '#Source.Worksheets("SUMMARY DATA SHEET")
Set sourceRange = wsSource.Range("A8:A18")
sourceFirstRow = sourceRange.Find("*", After:=wsSource.Range("A8")).Row
Set wsTarget = ThisWorkbook.Worksheets("Sheet2")
targetLastRow = wsTarget.Cells(Rows.Count, 2).End(xlUp).Row + 1
wsTarget.Range("B" & targetLastRow).Value = _
wsSource.Range("A" & sourceFirstRow).Value
wsTarget.Range("D" & targetLastRow).Value = _
wsSource.Range("D" & sourceFirstRow).Value
' etc...
End Sub
If you want to transfer the values from all cells in rows 8-18 that have data, also assuming that every row after the first row has data, then I think you just need to modify sourceRange
and make some change to the target using Resize
:
Sub foo()
Dim Source As Workbook
Dim wsTarget As Worksheet, wsSource As Worksheet
Dim sourceRange As Range
Dim targetLastRow As Long, sourceFirstRow As Long
Set Source = ThisWorkbook ' ### MODIFY AS NEEDED
Set wsSource = Source.Worksheets("Sheet1") '#Source.Worksheets("SUMMARY DATA SHEET")
Set sourceRange = wsSource.Range("A8:A18")
sourceFirstRow = sourceRange.Find("*", After:=wsSource.Range("A8")).Row
Set sourceRange = wsSource.Range("A" & sourceFirstRow & ":A18")
Set wsTarget = ThisWorkbook.Worksheets("Sheet2")
targetLastRow = wsTarget.Cells(Rows.Count, 2).End(xlUp).Row + 1
wsTarget.Range("B" & targetLastRow).Resize(sourceRange.Rows.Count, 1).Value = _
sourceRange.Value
wsTarget.Range("D" & targetLastRow).Resize(sourceRange.Rows.Count, 1).Value = _
sourceRange.Offset(, 3).Value
'etc...
End Sub
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…