How to exit for loop in excel-vba -
my dataset
i want make them
please @ first row.
my code is
private sub commandbutton1_click() dim mycolinstance, long dim myworksheetlastcolumn byte myworksheetlastcolumn = worksheets(1).cells(1, columns.count).end(xltoleft).column = 1 myworksheetlastcolumn mycolinstance = colinstance("preference", i) cells(1, mycolinstance).value = "preference" & next end sub function colinstance(headingstring string, instancenum long) dim colnum long on error resume next colnum = 0 x = 1 instancenum colnum = (range("a1").offset(0, colnum).column) + application.worksheetfunction.match(headingstring, range("a1").offset(0, colnum + 1).resize(1, columns.count - (colnum + 1)), 0) next colinstance = colnum end function
the problem while running code, shows error because loop not complete. can do?
can way? seems me adding suffix headers in first row...
sub updatecolumnheaders() dim headers range, header range, suffixes range, suffix range, integer set headers = range(cells(1, 1), cells(1, range("a1").end(xltoright).column)) set suffixes = range("a1:a" & range("a1").end(xldown).row) = 1 each header in headers if header = "preferences" header = header & suffixes(i) = + 1 end if next end sub
Comments
Post a Comment