Thursday 2 January 2020

excel - Range with blank cells copy and pasted into single column

I am trying to copy and paste a range that includes blank cells into a single column on another sheet. I would like the blanks to be ignored.




Here is the Frankenstein code I am using at the moment it is slow and a bit cluncky picture included to better describe



I would like to expand on it so that multiple ranges can paste into the same column ie find the last cell with a value and paste into the next cell.



i have been told it should look something like this



            'for r = 1 to 4
' for c = 1 to 8
' does rc have val,
' then copy to new sheet

' increment copy var
' increment c
' increment r


Sheets(Array("next record date")).Select
Range("G11:AZZ110").Select
If TypeName(Selection) = "Range" Then
If Selection.Count > 1 Then
If Selection.Count <= Selection.Parent.Rows.Count Then

vaCells = Selection.Value

ReDim vOutput(1 To UBound(vaCells, 1) * UBound(vaCells, 2), 1 To 1)

For j = LBound(vaCells, 2) To UBound(vaCells, 2)
For i = LBound(vaCells, 1) To UBound(vaCells, 1)
If Len(vaCells(i, j)) > 0 Then
lRow = lRow + 1
Sheets("Data").Select
Range("E2").Select

vOutput(lRow, 1) = vaCells(i, j)
Else
End If
Next i
Next j

Selection.ClearContents
Selection.Cells(1).Resize(lRow).Value = vOutput
End If
End If



End If



Thanks,



Jerome

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...