H
Howard
Each row in the C3:C10 range has various number of columns, and a few blanks in each row, arbitrary across row.
Want to copy and transpose each row, minus the blank cells to sheet 2.
I am happy with either the sheet 2 destination as Column A .xlup.offset(1,0) OR each copied row to a separate adjacent column on sheet 2.
This code below works "kinda okay" to copy and transpose on the same sheet.
I have tried to use Autofilter to "hide" the blanks in place and copy and transpose only the remaining row data to sheet 2, then turn Autofilter off to retain original data as was, blanks and all.
Lost of advice about Autofilter on columns, but cannot find something useful dealing with blanks in a row.
Thanks.
Howard
Option Explicit
Sub BlankOutSheet()
Dim c As Range, Rng As Range
Dim PnRow As String
Dim lCol As Long
Dim cRow As Long
PnRow = Range("C1")
For Each c In Range("C3:C10")
If c = PnRow Then
cRow = c.Row
lCol = Cells(cRow, Cells.Columns.Count).End(xlToLeft).Column
On Error Resume Next
c.Resize(1, lCol).Copy
Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial _
xlPasteValues, Transpose:=True
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
Application.CutCopyMode = False
End If
Next
End Sub
Want to copy and transpose each row, minus the blank cells to sheet 2.
I am happy with either the sheet 2 destination as Column A .xlup.offset(1,0) OR each copied row to a separate adjacent column on sheet 2.
This code below works "kinda okay" to copy and transpose on the same sheet.
I have tried to use Autofilter to "hide" the blanks in place and copy and transpose only the remaining row data to sheet 2, then turn Autofilter off to retain original data as was, blanks and all.
Lost of advice about Autofilter on columns, but cannot find something useful dealing with blanks in a row.
Thanks.
Howard
Option Explicit
Sub BlankOutSheet()
Dim c As Range, Rng As Range
Dim PnRow As String
Dim lCol As Long
Dim cRow As Long
PnRow = Range("C1")
For Each c In Range("C3:C10")
If c = PnRow Then
cRow = c.Row
lCol = Cells(cRow, Cells.Columns.Count).End(xlToLeft).Column
On Error Resume Next
c.Resize(1, lCol).Copy
Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial _
xlPasteValues, Transpose:=True
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
Application.CutCopyMode = False
End If
Next
End Sub