i have excel document plain text in row. a1:a5 contains text, several houndred rows down, there's few rows text. cells between empty. i've set do until loop supposed copy cells text, , stop when empty cell appears. loop counts&copies 136 cells includingthe 5 text. question why? bottom line: hello ends on line 136, , there's huge gap of empty cells until next area text. 131 white cells contain hidden formating causing this? i've tried "clear formats" , "clear all" code-snippet found below:
sub copytags_click() dim assets workbook, test workbook dim x integer, y integer set assets = workbooks.open("file-path.xlsx") set test = workbooks.open("file-path.xlsx") x = 1 y = 1 until assets.worksheets(1).range("a" & x) = "" test.worksheets(1).range("a" & y) = assets.worksheets(1).range("a" & x) x = x + 1 y = y + 1 loop test.worksheets(1).range("a" & x).value = "hello" end sub ive tried using vbnullstring instead of " "
use for next statement terminating in last used cell in column a. increment y if there has been value found , transferred , let ... next increment x.
sub copytags_click() dim assets workbook, test workbook dim x long, y long set assets = workbooks.open("file-path.xlsx") set test = workbooks.open("file-path.xlsx") x = 1 y = 1 assets.worksheets(1) x = 1 .cells(rows.count, 1).end(xlup).row if cbool(len(.range("a" & x).value2)) test.worksheets(1).range("a" & y) = assets.worksheets(1).range("a" & x) y = y + 1 end if next x test.worksheets(1).range("a" & y).value = "hello" end end sub
Comments
Post a Comment