excel - VBA: Range method failure -
i writing code select data entries of workbook 'open' in range, compiler gives error @ last line (set range rng)
dim wb workbook set wb = workbooks.open(range("c2") & range("c3")) 'here range("c2") & range("c3") contains location of file's path dim ws worksheet set ws = wb.activesheet dim frow long frow = ws.range("a" & rows.count).end(xlup).row dim rng range dim frow1 long frow1 = ws.cells(1, columns.count).end(xltoleft).column set rng = wb.activesheet.range(cells(1, 1), cells(frow, frow1))
try:
dim frow long frow = ws.range("a" & ws.rows.count).end(xlup).row dim rng range dim fcol long fcol = ws.cells(1, ws.columns.count).end(xltoleft).column set rng = ws.range(ws.cells(1, 1), ws.cells(frow, fcol))
remember if using set worksheet u have reference in range objects
Comments
Post a Comment