vba - Count rows starting in the middle of worksheet -


i have question cell count in vba excell workbook. trying write down text selected in combobox proper row (row 26 in picture) in excel changing if full (move next row) till row 32. if reaches row 33, write text in error window (not enough space). better wiev , understanding make picture expained. use following code hot working well:

private sub btnvzdrzevalna_click()  dim nvdsheet worksheet  set nvdsheet = thisworkbook.sheets("invd")  nr = nvdsheet.cells(rows.count, 1).end(xlup).row - 15  '- 15 leads right cell bottom of last cell allways returns same cell because last cell in rows.count same overwrites it.   nvdsheet.cells(nr, 2) = me.cmbvzdrzevanje nvdsheet.cells(nr, 3) = "stanovanjski zakon (sz-1)" nvdsheet.cells(nr, 4) = me.cmbizvajalec2 nvdsheet.cells(nr, 5) = me.cmbperioda nvdsheet.cells(nr, 6) = me.cmbpregled nvdsheet.cells(nr, 8) = me.tbcena1  end sub 

the picture better understanding of question

enter image description here

thank help. have nice day,

try these modifications:

private sub btnvzdrzevalna_click()  dim nvdsheet worksheet set nvdsheet = thisworkbook.sheets("invd")  dim nr long nr = 26  nvdsheet      'finds first empty row starting @ 26, not moving past 33     until isempty(.cells(nr, 2)) or nr = 33          nr = nr + 1      loop      if nr < 33          .cells(nr, 2) = me.cmbvzdrzevanje         .cells(nr, 3) = "stanovanjski zakon (sz-1)"         .cells(nr, 4) = me.cmbizvajalec2         .cells(nr, 5) = me.cmbperioda         .cells(nr, 6) = me.cmbpregled         .cells(nr, 8) = me.tbcena1      else          msgbox "not enough space"      end if  end  end sub 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -