Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Macro to "find" the next empty cell in a range


Thanks for help writing the macro.

Assumption: No price values are currently entered in the price cell
range (€œS&P 500€). Range B56:AF133 cells are all empty.

Each time the macro is run the next empty cell in Range B56:AF133 will
become the active cell.

Desired Outcome: Each time I run the macro (ctl-f) it locates the next empty
cell in the range as the active cell. A price value can then be entered in
the found cell, or another forward cell in the range.

Below is a script of how the macro should function.

Action: Run macro.
Outcome: Cursor should land in cell B56 (since no cell in range are
populated with a value).

Action: Enter a value in cell E56 (Jan. 4).

Action: Run macro.

Outcome: Cursor should land in cell F56 (since it is the next empty
cell in range).

Action: Enter a value in cell L56 (Jan. 11).

Action: Run macro.
Outcome: Cursor should land in cell M56 (since it is the next empty
cell in range).


Thank-you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro to "find" the next empty cell in a range

Try the below macro..

Sub Macro()

Dim varRange As Range

On Error Resume Next
Set varRange = Range("B56:AF133").SpecialCells(xlCellTypeBlanks)( 1, 1)
On Error GoTo 0
If varRange Is Nothing Then
Set varRange = Range("B" & Cells(Rows.Count, "B").End(xlUp).Row + 1)
End If
varRange.Select

End Sub


--
Jacob (MVP - Excel)


"Stilltrader47" wrote:


Thanks for help writing the macro.

Assumption: No price values are currently entered in the price cell
range (€œS&P 500€). Range B56:AF133 cells are all empty.

Each time the macro is run the next empty cell in Range B56:AF133 will
become the active cell.

Desired Outcome: Each time I run the macro (ctl-f) it locates the next empty
cell in the range as the active cell. A price value can then be entered in
the found cell, or another forward cell in the range.

Below is a script of how the macro should function.

Action: Run macro.
Outcome: Cursor should land in cell B56 (since no cell in range are
populated with a value).

Action: Enter a value in cell E56 (Jan. 4).

Action: Run macro.

Outcome: Cursor should land in cell F56 (since it is the next empty
cell in range).

Action: Enter a value in cell L56 (Jan. 11).

Action: Run macro.
Outcome: Cursor should land in cell M56 (since it is the next empty
cell in range).


Thank-you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro to "find" the next empty cell in a range

I think this should do what you want...

Sub FindNextEmptyCell()
On Error Resume Next
Range("B56:AF133").Find("").Select
If Err.Number Then Range("B56").Select
End Sub

--
Rick (MVP - Excel)



"Stilltrader47" wrote in message
...

Thanks for help writing the macro.

Assumption: No price values are currently entered in the price cell
range (€œS&P 500€). Range B56:AF133 cells are all empty.

Each time the macro is run the next empty cell in Range B56:AF133 will
become the active cell.

Desired Outcome: Each time I run the macro (ctl-f) it locates the next
empty
cell in the range as the active cell. A price value can then be entered
in
the found cell, or another forward cell in the range.

Below is a script of how the macro should function.

Action: Run macro.
Outcome: Cursor should land in cell B56 (since no cell in range
are
populated with a value).

Action: Enter a value in cell E56 (Jan. 4).

Action: Run macro.

Outcome: Cursor should land in cell F56 (since it is the next
empty
cell in range).

Action: Enter a value in cell L56 (Jan. 11).

Action: Run macro.
Outcome: Cursor should land in cell M56 (since it is the next
empty
cell in range).


Thank-you

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty a cell if the values equal to "IN" , "MC" or "PP" YHT Excel Programming 1 December 28th 07 06:59 AM
delete rows if cell in row contains "a" or "o" or empty bartman1980 Excel Programming 2 November 4th 07 08:20 PM
Enter "Empty" if cell is blank within a variable range ALATL Excel Programming 12 June 5th 07 08:14 PM
STOP MACRO IF CELL "A1" IS EMPTY OR SHEET DOESN΄T EXIST cbm Excel Programming 2 January 8th 07 10:00 AM


All times are GMT +1. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"