i have ton of excel sheets each have 3 excel workbook tabs. on last 1 there ton of data 1 column date column bunch of different dates underneath. date format mm/dd/yyyy. need advance each date ahead 4 years.
i imagine need select correct workbook, search particular column, , loop iterate through each value underneath column advance it, day needs stay same. example, if 10/05/2017, needs 10/05/2021. suggestions or great. thank in advance.
thank help, realize wasn't helpful @ question. i'm new vb script , excel macros in general. hadn't gotten how search column find column no matter column value (possibly search cell says "date" through entire sheet?, trying add 4 years start , couldn't find function needed. had derived , seems wrong ha.
do until isempty(activecell)
set thiscell = activecell thiscell = dateadd("yyyy", 4, columnvaluehere) ' step down 1 row present location. activecell.offset(1, 0).select loop
you'll wanting dateadd function
try this:
sub adddates() dim lastrow integer dim thesheetimworkingon worksheet dim thecolumnnumberforthedates integer thecolumnnumberforthedates = 5 ' change column number want set thesheetimworkingon = sheets("put sheet name here") lastrow = thesheetimworkingon.cells(1000000, thecolumnnumberforthedates ).end(xlup).row x = 2 lastrow ' assuming data starts on row 2 thesheetimworkingon.cells(x, thecolumnnumberforthedates) = dateadd("yyyy", 4, thesheetimworkingon.cells(x, thecolumnnumberforthedates)) next x end sub
Comments
Post a Comment