Find the first available (empty) cell on a worksheet.
Solved/Closed
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
-
Jan 17, 2015 at 01:17 PM
BrianGreen - Jan 21, 2015 at 07:28 PM
BrianGreen - Jan 21, 2015 at 07:28 PM
Related:
- Find the first available (empty) cell on a worksheet.
- Transfer data from one excel worksheet to another automatically - Guide
- Clear only the formatting from the selected cell (leaving the content) - Guide
- Insert a new sheet at the end of the tab names and paste the range names starting in cell a1. autofit columns a:b and name the worksheet as range names. ✓ - Excel Forum
- Conditional formatting if cell contains text - Excel Forum
- Count if cell contains number - Excel Forum
7 responses
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 19, 2015 at 03:11 PM
Jan 19, 2015 at 03:11 PM
Hi Ray,
Thanks for that . Nice!
Cheers,
vcoolio.
Thanks for that . Nice!
Cheers,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 18, 2015 at 06:57 AM
Jan 18, 2015 at 06:57 AM
Hello Brian,
If you are just wanting to find the empty cell(s) and highlight it (them), then this simple macro should do the job for you:-
You can change the colour index to suit yourself.
Alternatively, you can just use the in-built Excel find function:
Home tab--->Editing--->Find & Select. In the menu that appears, select Go To Special. In the Go To Special dialogue box that appears, select blanks then OK.
Hopefully, this is what you were after.
Cheers,
vcoolio.
If you are just wanting to find the empty cell(s) and highlight it (them), then this simple macro should do the job for you:-
Sub PickTheBlanks() ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Select Selection.Interior.ColorIndex = 8 End Sub
You can change the colour index to suit yourself.
Alternatively, you can just use the in-built Excel find function:
Home tab--->Editing--->Find & Select. In the menu that appears, select Go To Special. In the Go To Special dialogue box that appears, select blanks then OK.
Hopefully, this is what you were after.
Cheers,
vcoolio.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 19, 2015 at 09:40 AM
Jan 19, 2015 at 09:40 AM
Thanks vcoolio.
Im not sure this is what I need, but is closer than where I was! I will investigate the commands you suggest and see if I can make it work, but ...
I want to be able to insert data into a single empty cell from another page of the workbook. I cant try your code until tomorrow, but Im guessing the first line (not the "sub" line) selects ALL empty cells. I just need the first available cell (it doesnt really matter which empty cell in the range as long as there is only one cell selected). the next empty cell will be filled when the need arises to use this macro again.
Thanks again for your help so far.
Im not sure this is what I need, but is closer than where I was! I will investigate the commands you suggest and see if I can make it work, but ...
I want to be able to insert data into a single empty cell from another page of the workbook. I cant try your code until tomorrow, but Im guessing the first line (not the "sub" line) selects ALL empty cells. I just need the first available cell (it doesnt really matter which empty cell in the range as long as there is only one cell selected). the next empty cell will be filled when the need arises to use this macro again.
Thanks again for your help so far.
RayH
>
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
Jan 19, 2015 at 11:41 AM
Jan 19, 2015 at 11:41 AM
To expand on vcoolio's answer:
For Each c In UsedRange.SpecialCells(xlCellTypeBlanks)
c.Interior.ColorIndex = 8
Exit Sub
Next
This will find the 1st empty cell and color it.
The search is done across and then down.
For Each c In UsedRange.SpecialCells(xlCellTypeBlanks)
c.Interior.ColorIndex = 8
Exit Sub
Next
This will find the 1st empty cell and color it.
The search is done across and then down.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 19, 2015 at 12:06 PM
Jan 19, 2015 at 12:06 PM
Thank you to you both.
I will try this tomorrow and let you know that it works.
Thank you again.
I will try this tomorrow and let you know that it works.
Thank you again.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 20, 2015 at 08:32 AM
Jan 20, 2015 at 08:32 AM
Awww :(
Thanks for your efforts so far guys, but I get the following message:
Run-time error '424':
Object required
When I debug, the "For Each c In UsedRange.SpecialCells(xlCellTypeBlanks)" line is highlighted.
The macro I have so far does this on a different sheet in this workbook ...
- checks there are no errors in data that humans put in column A,
- sorts the data
- spaces it nicely so it is presented nicely to humans.
At this point I am using the following code to switch to the required sheet where the blank spaces are (followed buy your code).
Sheets("Data").Select
For Each c In UsedRange.SpecialCells(xlCellTypeBlanks).Select
c.Interior.ColorIndex = 8
Exit For
Next
vcoolio's answer does indeed perform the same action on all empty cells.
I am sure you are correct and I am close in getting what I want, but I just cant make that final jump.
I'll keep trying and researching, but if you could spell it out so a blind man could see, then I would be so happy that I would buy you a drink (tea/coffee) whenever you asked me!
Thanks for your time and help.
Thanks for your efforts so far guys, but I get the following message:
Run-time error '424':
Object required
When I debug, the "For Each c In UsedRange.SpecialCells(xlCellTypeBlanks)" line is highlighted.
The macro I have so far does this on a different sheet in this workbook ...
- checks there are no errors in data that humans put in column A,
- sorts the data
- spaces it nicely so it is presented nicely to humans.
At this point I am using the following code to switch to the required sheet where the blank spaces are (followed buy your code).
Sheets("Data").Select
For Each c In UsedRange.SpecialCells(xlCellTypeBlanks).Select
c.Interior.ColorIndex = 8
Exit For
Next
vcoolio's answer does indeed perform the same action on all empty cells.
I am sure you are correct and I am close in getting what I want, but I just cant make that final jump.
I'll keep trying and researching, but if you could spell it out so a blind man could see, then I would be so happy that I would buy you a drink (tea/coffee) whenever you asked me!
Thanks for your time and help.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
>
RayH
Jan 21, 2015 at 02:51 AM
Jan 21, 2015 at 02:51 AM
Yes - Sorry - That was a result of me trying lots of things and copying and pasting what I had instead of what I wanted.
I have tried the script you suggest, with the same responce from Excel:
Run-time error '424':
Object required
Sorry for the miss-information on last post.
I also appologise for the time this is dragging on - it doesnt help with us being on different time zones. Please bear with me with this.
I have tried the script you suggest, with the same responce from Excel:
Run-time error '424':
Object required
Sorry for the miss-information on last post.
I also appologise for the time this is dragging on - it doesnt help with us being on different time zones. Please bear with me with this.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 21, 2015 at 03:45 AM
Jan 21, 2015 at 03:45 AM
Hello Brian,
The "required object" would probably be the active sheet. So, in Ray's code, make the following minor adjustment:-
You would be better off to use Ray's code as you will no doubt be wanting to deal with one empty cell at a time, not a whole group of them as my initial code shows.
So, its over to you Ray, I'm off to work now (for the second time today!).
Cheers Gentlemen,
vcoolio.
The "required object" would probably be the active sheet. So, in Ray's code, make the following minor adjustment:-
Sub PickTheBlanks() For Each c In ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks) c.Interior.ColorIndex = 8 Exit For Next End Sub
You would be better off to use Ray's code as you will no doubt be wanting to deal with one empty cell at a time, not a whole group of them as my initial code shows.
So, its over to you Ray, I'm off to work now (for the second time today!).
Cheers Gentlemen,
vcoolio.
Didn't find the answer you are looking for?
Ask a question
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 21, 2015 at 03:53 AM
Jan 21, 2015 at 03:53 AM
GUYS ....
Thank you so much!
I finally solved this using RayH's code but with a very subtle change.
My final code was:
For Each c In Sheets("Data").UsedRange.SpecialCells(xlCellTypeBlanks)
c.Interior.ColorIndex = 8
Exit For
Next
I have no idea why I had to declare the sheet in your code as it is already the active sheet, but perhaps that will come with experience.
I really do appreciate your help - I could never have solved this without you.
As for allocating kudos, I have seen on some blogs that people are only able to allocate kudos to one person, so this has to go to RayH as he was able to narrow the selection to one cell, but If I am able to give you both credit, then I will - its my first time here so not sure quite how this goes.
Thanks again.
Thank you so much!
I finally solved this using RayH's code but with a very subtle change.
My final code was:
For Each c In Sheets("Data").UsedRange.SpecialCells(xlCellTypeBlanks)
c.Interior.ColorIndex = 8
Exit For
Next
I have no idea why I had to declare the sheet in your code as it is already the active sheet, but perhaps that will come with experience.
I really do appreciate your help - I could never have solved this without you.
As for allocating kudos, I have seen on some blogs that people are only able to allocate kudos to one person, so this has to go to RayH as he was able to narrow the selection to one cell, but If I am able to give you both credit, then I will - its my first time here so not sure quite how this goes.
Thanks again.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 21, 2015 at 03:58 AM
Jan 21, 2015 at 03:58 AM
Sorry Ray - there is no options to give you any credit. If anyone can tell me how I can give you it then please let me know.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
Jan 21, 2015 at 05:56 AM
Jan 21, 2015 at 05:56 AM
Ah - first thought was it was good, but I tried adding titles to columns in the range A1:AL3 but leaving some of the cells empty. Now the cells are shading in on the empty cells that are in the title area. I could put data in these cells and format them to be white on white, so they are no longer empty, but is there a better solution so the macro fills in empty cells in the range A4:AL54 ?
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 21, 2015 at 06:50 AM
Jan 21, 2015 at 06:50 AM
Hello Brian,
Try this minor alteration:-
Change:
to:
This should take care of the titles problem.
Cheers,
vcoolio.
Try this minor alteration:-
Change:
For Each c In Sheets("Data").UsedRange.SpecialCells(xlCellTypeBlanks)
to:
For Each c In Sheets("Data").Range("A4:AL54").SpecialCells(xlCellTypeBlanks)
This should take care of the titles problem.
Cheers,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
>
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
Jan 21, 2015 at 07:09 AM
Jan 21, 2015 at 07:09 AM
Or, if you don't want to be locked in to a fixed range, try:-
Cheers,
vcoolio.
For Each c In Sheets("Data").UsedRange.Offset(3, 0).SpecialCells(xlCellTypeBlanks)
Cheers,
vcoolio.
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
149
>
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
Jan 21, 2015 at 09:01 AM
Jan 21, 2015 at 09:01 AM
Absoluteley Marvelous!
Thank you so much!
I had forgotten about the offset command dispite using it so much in an earlier script. Im getting old and forgetful!
Oh the irony - its taking me so long to learn new stuff because Im of the age that the old stuff is forgotten ...
Thanks again.
Thank you so much!
I had forgotten about the offset command dispite using it so much in an earlier script. Im getting old and forgetful!
Oh the irony - its taking me so long to learn new stuff because Im of the age that the old stuff is forgotten ...
Thanks again.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 21, 2015 at 07:01 PM
Jan 21, 2015 at 07:01 PM
Hi Brian,
I'm glad that it has all worked out for you.
@Ray:-
Thanks Ray. Nothing like collaboration. Three heads are better than one!!??!!
Cheers Gentlemen,
vcoolio.
I'm glad that it has all worked out for you.
@Ray:-
Thanks Ray. Nothing like collaboration. Three heads are better than one!!??!!
Cheers Gentlemen,
vcoolio.
Jan 19, 2015 at 06:48 PM