Mr_Ragweed2
Board Regular
- Joined
- Nov 11, 2022
- Messages
- 145
- Office Version
- 365
- Platform
- Windows
Hello and much thanks in advance. I'm trying to write a loop that searches a range of rows (19-31) and if there is data in column C for that row then i want t paste columns C:U from that row into another sheet. It's been a long time since i've done this and VBA is not part of my regular work - so apologies for simple errors.
[Code starts here]
Dim i As Integer
For i = 19 To 31 These are the only rows that could contain data. it may be zero rows or all of them.
ThisFinal = Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Dekalb Seed Order Form").Cells(i, 3).Value <> "" Then
Sheets("Form Sheet").Rows(i).Select -This is where i'm wrong. This selects the whole row and i just want columns C:U from each row with data.
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.UnMerge (required due to huge formatting differences btwn the sheets)
Selection.Copy
Sheets("Order Summary").Select This is my attempt to paste it to the next available row on a different sheet
Cells(ThisFinal + 1, 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Form Sheet").Activate
End If
Next i
[end code]
(sorry about code tags being wrong)
[Code starts here]
Dim i As Integer
For i = 19 To 31 These are the only rows that could contain data. it may be zero rows or all of them.
ThisFinal = Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Dekalb Seed Order Form").Cells(i, 3).Value <> "" Then
Sheets("Form Sheet").Rows(i).Select -This is where i'm wrong. This selects the whole row and i just want columns C:U from each row with data.
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.UnMerge (required due to huge formatting differences btwn the sheets)
Selection.Copy
Sheets("Order Summary").Select This is my attempt to paste it to the next available row on a different sheet
Cells(ThisFinal + 1, 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Form Sheet").Activate
End If
Next i
[end code]
(sorry about code tags being wrong)