0

does anyone one how to instead of static range:

 '~~> Copy the range
    wsI.Range("A1:K50").Copy

To change it to dynamic where A1:A50 is calculated depending on non-blank cells.

So if Sheet1 has 23 lines and the rest of them are blank so range would be: A1:K23?

R3uK
  • 14,417
  • 7
  • 43
  • 77
Freedox
  • 123
  • 2
  • 4
  • 11

1 Answers1

0

just in case someone looks for an answer:

issue - when copying data from other sheet where I had formulas, pasted cells are blank, but not actually blank. It holds some sort of 'nothing'...

  • solution ,SpecialCells(xlCellTypeVisible).Copy to copy data and paste in the same workbook with Paste:=xlPasteValuesAndNumberFormats (it holds date value as this was something I needed). Then used "find and replace" code to clear "blank, but not blank" cells.

'~~> Find "" and replace with pneumonoultramicroscopicsilicovolcanoconiosis

Worksheets("paste").Range("A1:K500").Cells.Replace What:="", Replacement:="pneumonoultramicroscopicsilicovolcanoconiosis", LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

'~~> Find pneumonoultramicroscopicsilicovolcanoconiosis and replace with ""

Worksheets("paste").Range("A1:K500").Cells.Replace What:="pneumonoultramicroscopicsilicovolcanoconiosis", Replacement:="", LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
Freedox
  • 123
  • 2
  • 4
  • 11