vba - Code to rename existing worksheets from cell value in worksheet 1 if value in another cell -
i quite know nothing macros , vba codes. have tried several different things nothing working. trying create template sheet1 list of part numbers either make or buy make product sell. column b part number , column e either m or b make or buy. rename existing worksheet (starting sheet3) part number listed in column b if there m in column e. please help, confused on this. need existing following sheets named parts make , not ones buy.
thank you.
paste in standard module (alt+f11, right-click vbaproject on left > insert > module).
this may need tweaked little bit exact needs, asking in question should job.
option explicit sub createsheets() dim rngb range, rnge range, mysheet worksheet, cell range dim row long, newsheet worksheet set mysheet = thisworkbook.sheets(1) set rngb = mysheet.range("b:b") set rnge = mysheet.range("e:e") each cell in rnge row = cell.row if cell = empty exit else if cell.value = "m" set newsheet = thisworkbook.sheets.add(after:=sheets(worksheets.count)) newsheet .name = mysheet.cells(row, 2) end set newsheet = nothing end if end if next cell end sub
then need click alt+f8 run macro.
Comments
Post a Comment