tablecolumn - Excel VBA - add column to right and fill with text -
i want edit existing code (below), copies , pastes tables between 2 workbooks, following:
- add new column right of "vdb" (at end) copy of table wbtarget
- populate entire column text "total"
then paste workbook called "sht1"
dim vdb variant dim sht1 worksheet dim wbtarget workbook 'if sheet name "total" then... if "total" = sheet.name 'copy given range target workbook vdb = wbtarget.sheets(sheet.name).range("b3:i102") 'paste range under existing data in master workbook sht1.range("a" & rows.count).end(xlup)(2).resize(ubound(vdb, 1), ubound(vdb, 2)) = vdb end if
my failed attempt:
dim vdb variant dim sht1 worksheet dim wbtarget workbook if "total" = sheet.name vdb = wbtarget.sheets(sheet.name).range("b3:i102") vdb .listcolumns.add x = .listcolumns.count .range(2, x) = "total" end sht1.range("a" & rows.count).end(xlup)(2).resize(ubound(vdb, 1), ubound(vdb, 2)) = vdb end if i "object required" error. suggestions? i'm new vba...
add code line below @ end of current code:
' adding "total" last column on right sht1.range("a1").offset(, ubound(vdb, 2)).resize(ubound(vdb, 1) + 1, 1).value2 = "total"
Comments
Post a Comment