Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro select next blank cell in a row

Hi, I'm trying to do a macro that will automaticly select the first blank
cell that will appear in a row, I have tried the following but it doesn't
select the cell but my message box will give me the right cell adress for the
empty cell.

Sub A()
Dim myCell As Range
Dim NextEmpty As Range

Set myCell = ActiveSheet.Range("c5")
Do
If myCell.Value = "" Then
Set NextEmpty = myCell
Exit Do
Else
Set myCell = myCell.Offset(0, 1)
End If
Loop

MsgBox NextEmpty.Address

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default macro select next blank cell in a row

Change:
MsgBox NextEmpty.Address
to
nextempty.select

But for lots of things, you don't have to select the range to work with it:

with nextempty
.value = date
.numberformat = "mm/dd/yyyy"
end with

(If I wanted the date in that cell.)

raph_baril wrote:

Hi, I'm trying to do a macro that will automaticly select the first blank
cell that will appear in a row, I have tried the following but it doesn't
select the cell but my message box will give me the right cell adress for the
empty cell.

Sub A()
Dim myCell As Range
Dim NextEmpty As Range

Set myCell = ActiveSheet.Range("c5")
Do
If myCell.Value = "" Then
Set NextEmpty = myCell
Exit Do
Else
Set myCell = myCell.Offset(0, 1)
End If
Loop

MsgBox NextEmpty.Address

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default macro select next blank cell in a row

Add NextEmpty.Select in the line before or after the MsgBox
line.


Doug


raph_baril wrote in message
...
Hi, I'm trying to do a macro that will automaticly select the first blank
cell that will appear in a row, I have tried the following but it doesn't
select the cell but my message box will give me the right cell adress for

the
empty cell.

Sub A()
Dim myCell As Range
Dim NextEmpty As Range

Set myCell = ActiveSheet.Range("c5")
Do
If myCell.Value = "" Then
Set NextEmpty = myCell
Exit Do
Else
Set myCell = myCell.Offset(0, 1)
End If
Loop

MsgBox NextEmpty.Address

End Sub





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
How can I select the first blank cell Valdemar[_2_] Excel Worksheet Functions 4 January 18th 10 12:04 PM
Is there a formula to select the last non-blank cell in a list BROCK8292 Excel Discussion (Misc queries) 10 March 25th 08 12:32 AM
How do I select & use contents of first non-blank cell in row? plf100 Excel Worksheet Functions 9 November 15th 05 12:16 PM
I want to select the first blank cell in column A Greegan Excel Worksheet Functions 7 March 13th 05 12:56 PM
Select blank cell Hodar Excel Programming 6 January 21st 04 02:18 PM


All times are GMT +1. The time now is 11:40 PM.

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"