Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Jumping in a For ..Next Loop

XL2002

My basic macro is:-

Sub ABC()

Newtext = ""
For C = 1 to 5
For R = 1 to 10
newtext = newtext & Cells(R,C)
next R
Cells(r,12) = newtext
newtext = ""
next C

End

I.E. I want to concatenate the text in Column A rows 1 - 10 and put the
result in L1
Then do the same for column B and put the result in L2 and so on

However, I want to ignore any blank cells - i.e. do not insert any ""s into
the strings.

I've tried inserting what I would call a forced jump [as below in caps]

Sub ABC()

Newtext = ""
For C = 1 to 5
For R = 1 to 10

IF CELLS(R,C) = "" THEN NEXT R

newtext = newtext & Cells(R,C)
next R
Cells(r,12) = newtext
newtext = ""
next C

End

in other words ; if the cell concerned is blank then jump to the next row
but this doesn't work.

I thought that it could be that the forced NEXT R instruction is putting R
out of its For...Next range but it happens even when R is below 10

What am I doing wrong?

Thanks

Bertrand








  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Jumping in a For ..Next Loop

For R = 1 to 10
IF CELLS(R,C) < "" THEN newtext = newtext & Cells(R,C)
next R

"Bertrand" wrote:

XL2002

My basic macro is:-

Sub ABC()

Newtext = ""
For C = 1 to 5
For R = 1 to 10
newtext = newtext & Cells(R,C)
next R
Cells(r,12) = newtext
newtext = ""
next C

End

I.E. I want to concatenate the text in Column A rows 1 - 10 and put the
result in L1
Then do the same for column B and put the result in L2 and so on

However, I want to ignore any blank cells - i.e. do not insert any ""s into
the strings.

I've tried inserting what I would call a forced jump [as below in caps]

Sub ABC()

Newtext = ""
For C = 1 to 5
For R = 1 to 10

IF CELLS(R,C) = "" THEN NEXT R

newtext = newtext & Cells(R,C)
next R
Cells(r,12) = newtext
newtext = ""
next C

End

in other words ; if the cell concerned is blank then jump to the next row
but this doesn't work.

I thought that it could be that the forced NEXT R instruction is putting R
out of its For...Next range but it happens even when R is below 10

What am I doing wrong?

Thanks

Bertrand









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
jumping around raulavi Excel Discussion (Misc queries) 11 September 9th 07 01:28 AM
Jumping Between Sheets! lzweifel Excel Discussion (Misc queries) 3 April 6th 06 09:40 PM
Cut and Paste Jumping wilro85[_7_] Excel Programming 0 December 14th 05 12:31 AM
Page jumping Alarmbloke Excel Discussion (Misc queries) 0 December 12th 05 10:01 AM
Jumping columns Lolly Excel Discussion (Misc queries) 3 November 18th 05 03:17 AM


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