Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get for loop to go on after blank cell?

I have this code which checks through the cells of a column. When i
finds a value it checks through the cases and if it finds a match i
writes data as specified in the case.

The problem I am having is that when it hits a blank cell it stops.
How can I get it to continue on?


Code
-------------------

Columns("J:J").Select
Dim c As Range
For Each c In Selection
Select Case UCase(c)
Case "LTCOL"
Range("I" & c.Row).Value = "1"
Case "MAJ"
Range("I" & c.Row).Value = "2"
Case "CAPT"
Range("I" & c.Row).Value = "3"
Case "LT"
Range("I" & c.Row).Value = "4"
Case "WO1"
Range("I" & c.Row).Value = "5"
Case "WO2"
Range("I" & c.Row).Value = "6"
Case "SGT"
Range("I" & c.Row).Value = "7"
Case "CPL"
Range("I" & c.Row).Value = "8"
Case "LCPL"
Range("I" & c.Row).Value = "9"
Case "PTE"
Range("I" & c.Row).Value = "10"
Case "APS"
Range("I" & c.Row).Value = "11"
Case ""
Range("I" & c.Row).Value = "12"

Exit For
End Select

Next c

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


--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default get for loop to go on after blank cell?

Try adding

Select Case ""
' do nothing


"john_t_h " wrote in message
...
I have this code which checks through the cells of a column. When it
finds a value it checks through the cases and if it finds a match it
writes data as specified in the case.

The problem I am having is that when it hits a blank cell it stops.
How can I get it to continue on?


Code:
--------------------

Columns("J:J").Select
Dim c As Range
For Each c In Selection
Select Case UCase(c)
Case "LTCOL"
Range("I" & c.Row).Value = "1"
Case "MAJ"
Range("I" & c.Row).Value = "2"
Case "CAPT"
Range("I" & c.Row).Value = "3"
Case "LT"
Range("I" & c.Row).Value = "4"
Case "WO1"
Range("I" & c.Row).Value = "5"
Case "WO2"
Range("I" & c.Row).Value = "6"
Case "SGT"
Range("I" & c.Row).Value = "7"
Case "CPL"
Range("I" & c.Row).Value = "8"
Case "LCPL"
Range("I" & c.Row).Value = "9"
Case "PTE"
Range("I" & c.Row).Value = "10"
Case "APS"
Range("I" & c.Row).Value = "11"
Case ""
Range("I" & c.Row).Value = "12"

Exit For
End Select

Next c

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



---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default get for loop to go on after blank cell?

Would any ideas here help? This is not complete, just something thrown
together to give an idea.

v = Array("LTCOL", "MAJ", "CAPT", "LT", "WO1", "WO2", "SGT", "CPL",
"LCPL", "PTE", "APS")

For Each c In Columns("J:J").SpecialCells(xlTextValues)
Cells(c.Row, 9) = WorksheetFunction.Match(c.Value, v)
Next


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"john_t_h " wrote in message
...
I have this code which checks through the cells of a column. When it
finds a value it checks through the cases and if it finds a match it
writes data as specified in the case.

The problem I am having is that when it hits a blank cell it stops.
How can I get it to continue on?


Code:
--------------------

Columns("J:J").Select
Dim c As Range
For Each c In Selection
Select Case UCase(c)
Case "LTCOL"
Range("I" & c.Row).Value = "1"
Case "MAJ"
Range("I" & c.Row).Value = "2"
Case "CAPT"
Range("I" & c.Row).Value = "3"
Case "LT"
Range("I" & c.Row).Value = "4"
Case "WO1"
Range("I" & c.Row).Value = "5"
Case "WO2"
Range("I" & c.Row).Value = "6"
Case "SGT"
Range("I" & c.Row).Value = "7"
Case "CPL"
Range("I" & c.Row).Value = "8"
Case "LCPL"
Range("I" & c.Row).Value = "9"
Case "PTE"
Range("I" & c.Row).Value = "10"
Case "APS"
Range("I" & c.Row).Value = "11"
Case ""
Range("I" & c.Row).Value = "12"

Exit For
End Select

Next c

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



---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get for loop to go on after blank cell?

What I ended up doing was getting the macro to write some dummy data to
the blank cells by referencing another column that never has blank
cells.

That way I just added in another case for the dummy data and all is
good.

:)


---
Message posted from http://www.ExcelForum.com/

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
Loop through last cell/row of used range tkraju via OfficeKB.com Excel Discussion (Misc queries) 1 April 4th 09 04:45 PM
Average Formula to display blank cell if named range is blank Rachael F Excel Worksheet Functions 3 February 22nd 08 05:05 PM
how to get excel to display blank if reference cell blank silent1(not) Excel Worksheet Functions 1 December 2nd 05 02:49 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 09:15 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"