Question:
Excel VBA - I'm trying to find the next empty cell to the right of a specified cell - Any ideas?
adam w
2008-12-10 11:08:12 UTC
The cell I have text in is "BA18." I have to select an empty one next to it, to place a validation list but since this row of cells will continue to expand across to the right of "BA18" when an option box is clicked, I want to use VBA to locate consecutive empty cells, to then validate lists.

The reason I can't just record a VBA to insert a column and then validate it is because the information would read in the wrong order from newest to oldest - when I want oldest to newest.

I looked on the Internet, all evening, but I just get coding which scrolls right down to the end of the sheet - or just doesn't seem to work at all.

Any help would be appreciated. Cheers!
Four answers:
Cozmosis
2008-12-11 02:22:25 UTC
This will select the first empty cell to the right of BA18

Range("BA18").End(xlToRight).Offset(0, 1).Select



This will select the first empty cell just to the right of the last cell used in row 18.

Range("IV18").End(xlToLeft).Offset(0, 1).Select
?
2017-01-20 01:13:23 UTC
1
?
2016-10-16 08:15:01 UTC
I examine the link you provided. It became very interesting, and made some solid factors. i ask your self, however... did you examine it? It would not recent the as-is advent and/or layout which you seem to hold to. It revolves around nicely-known abiogenesis, and the formation of existence by completely organic purposes, yet posits that the organic rules of the universe have been set up such that existence would upward thrust up for sure. this is in simple terms *one* of his conclusions - the others are that wonderful-tuning is in simple terms an phantasm, and that wonderful-tuning exists yet no longer because of the fact the end results of an smart stress. that's no longer information of layout, however. It would not conflct with layout, in spite of the incontrovertible fact that it incredibly isn't any longer information of layout. it incredibly is actual a solid occasion of ways faith and technology can co-exist. existence arose in accordance to the organic rules of the universe. we don't comprehend why those rules are the way they're, so in case you prefer to have self assurance that they have been set by skill of God with the certainty and reason that that they had bring about humanity 14-unusual billion years later, there is no conflict. the theory that we've been created as-is, or that we've been immediately designed in violation of the organic rules of the universe in simple terms isn't supported by skill of the information, however.
ArmchairPilot
2008-12-10 11:58:16 UTC
This code will give you the column number of the first empty cell to the right of BA18:



sRow = 18

sCol = 54



Do While (Not IsEmpty(Cells(sRow, sCol)))

  sCol = sCol + 1

Loop



' Cells(sRow, sCol) = some value ??

-------------------------------------------------------------------



EDIT

Cells(sRow,sCol).Select


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...