excel vba - userform textbox to function if kept blank -


i have created useform helps me change column width , row height of active sheet or sheets (based on selection option in frame3) column b or column c (based on selection option in frame2) based on text entered in textbox1 , textbox2. have attacahed userform reference. userform

this code working fine, if need change column width not row height when key in column width , leave row height empty giving me error on below mentioned line: selection.cells.rowheight = me.textbox2.value

please let me know how should modify code if of textbox value left blank (i.e if want change column width , maintain row height as-is) should not give me error.

userform code:

dim exworkb workbook dim xlwksht worksheet dim lastrow1 long dim lastcolumn1 long dim firstrowdb long dim z integer dim shtnames() string  private sub commandbutton1_click()  if me.optionbutton3.value = true     if me.optionbutton1.value = true         call rowcolactivesheetb         selection.cells.rowheight = me.textbox2.value         selection.cells.columnwidth = me.textbox1.value     elseif me.optionbutton2.value = true         redim shtnames(1 activeworkbook.sheets.count)         z = 1 sheets.count             shtnames(z) = sheets(z).name             if shtnames(z) <> "trans_letter" , shtnames(z) <> "cover" , shtnames(z) <> "abbreviations" , instr(shtnames(z), "_index") = 0                 sheets(z).select                 lastrow1 = sheets(z).cells(rows.count, "a").end(xlup).row                 lastcolumn1 = sheets(z).cells(1, columns.count).end(xltoleft).column                 activeworkbook.sheets(z).range(sheets(z).cells(1, 2), sheets(z).cells(lastrow1, lastcolumn1)).select                 selection.cells.rowheight = me.textbox2.value                 selection.cells.columnwidth = me.textbox1.value             end if         next z     end if end if  if me.optionbutton4.value = true     if me.optionbutton1.value = true         call rowcolactivesheetc         selection.cells.rowheight = me.textbox2.value         selection.cells.columnwidth = me.textbox1.value     elseif me.optionbutton2.value = true         redim shtnames(1 activeworkbook.sheets.count)         z = 1 sheets.count             shtnames(z) = sheets(z).name             sheets(z).select             if shtnames(z) <> "trans_letter" , shtnames(z) <> "cover" , shtnames(z) <> "abbreviations" , instr(shtnames(z), "_index") = 0                 lastrow1 = sheets(z).cells(rows.count, "a").end(xlup).row                 lastcolumn1 = sheets(z).cells(1, columns.count).end(xltoleft).column                 activeworkbook.sheets(z).range(sheets(z).cells(1, 3), sheets(z).cells(lastrow1, lastcolumn1)).select                 selection.cells.rowheight = me.textbox2.value                 selection.cells.columnwidth = me.textbox1.value             end if         next z     end if end if  end sub  private sub commandbutton2_click()  unload me  end sub 

module code:

sub rowcolactivesheetb()  dim exworkb workbook dim xlwksht worksheet dim lastrow1 long dim lastcolumn1 long dim firstrowdb long  activesheet     lastrow1 = .cells(rows.count, "a").end(xlup).row     lastcolumn1 = .cells(1, columns.count).end(xltoleft).column     .range(.cells(1, 2), .cells(lastrow1, lastcolumn1)).select end  end sub 

sub rowcolactivesheetc()  dim exworkb workbook dim xlwksht worksheet dim lastrow1 long dim lastcolumn1 long dim firstrowdb long  activesheet     lastrow1 = .cells(rows.count, "a").end(xlup).row     lastcolumn1 = .cells(1, columns.count).end(xltoleft).column     .range(.cells(1, 3), .cells(lastrow1, lastcolumn1)).select end  end sub 


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -