Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
UniDave
 
Posts: n/a
Default empty cells in ranges


I am building a macro which will populate a range but I need to know how
to goto the next empty cell in that range

Any suggestions, good people?


--
UniDave
------------------------------------------------------------------------
UniDave's Profile: http://www.excelforum.com/member.php...o&userid=16844
View this thread: http://www.excelforum.com/showthread...hreadid=320492

  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi UniDave,

Perhaps you could use something like:

Sub Tester03()
Dim rng As Range
Dim rng1 As Range
Dim rngArea As Range
Dim rCell As Range
Dim i As Long, j As Long

Set rng = Range("A1:D20") '<<===== CHANGE
On Error Resume Next 'In case there are no blanks!
Set rng1 = rng.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

For Each rngArea In rng1
For j = 1 To rngArea.Columns.Count
For Each rCell In rngArea.Columns(j)
'Add your populating code, e.g:
i = i + 1
rCell = i * 2
Next rCell
Next j
Next rngArea
End Sub

If you need further assistance, it would be useful to know your population
criteria.

---
Regards,
Norman



"UniDave" wrote in message
...

I am building a macro which will populate a range but I need to know how
to goto the next empty cell in that range

Any suggestions, good people?


--
UniDave
------------------------------------------------------------------------
UniDave's Profile:
http://www.excelforum.com/member.php...o&userid=16844
View this thread: http://www.excelforum.com/showthread...hreadid=320492



  #3   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi UniDave,

In case there are no blanks, better would be

Sub Tester03()
Dim rng As Range
Dim rng1 As Range
Dim rngArea As Range
Dim rCell As Range
Dim i As Long, j As Long

Set rng = Range("A1:D20") '<<===== CHANGE
On Error Resume Next 'In case there are no blanks!
Set rng1 = rng.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Not rng1 Is Nothing Then
For Each rngArea In rng1
For j = 1 To rngArea.Columns.Count
For Each rCell In rngArea.Columns(j)
'Add your populating code, e.g:
i = i + 1
rCell = i * 2
Next rCell
Next j
Next rngArea
Else
MsgBox "There are no blank cells!"
End If
End Sub

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi UniDave,

Perhaps you could use something like:

Sub Tester03()
Dim rng As Range
Dim rng1 As Range
Dim rngArea As Range
Dim rCell As Range
Dim i As Long, j As Long

Set rng = Range("A1:D20") '<<===== CHANGE
On Error Resume Next 'In case there are no blanks!
Set rng1 = rng.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

For Each rngArea In rng1
For j = 1 To rngArea.Columns.Count
For Each rCell In rngArea.Columns(j)
'Add your populating code, e.g:
i = i + 1
rCell = i * 2
Next rCell
Next j
Next rngArea
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
Trendlines to ignore empty cells Hoochi Coochi Man Charts and Charting in Excel 7 January 14th 05 01:31 PM
make a cell empty based on condition mpierre Charts and Charting in Excel 2 December 29th 04 01:01 PM
Problem with graph ranges No Such Luck Charts and Charting in Excel 6 December 3rd 04 01:09 PM
compare unique identifiers in multiple ranges bawilli_91125 Charts and Charting in Excel 1 November 30th 04 06:34 PM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM


All times are GMT +1. The time now is 12:55 PM.

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

About Us

"It's about Microsoft Excel"