Thread: Code Question
View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Code Question

The only thing my code did differently was to start in column K if it was
empty. But you are saying you want to stop processing if column K is
empty - so I am confused. Perhaps you could show a bit more of your code -
if you are looping backwards and always will fill in values in columns K to
R, there may be a way to do it like

for ii = lastrow to 1 step -1
if isempty(Range("K" & i)) then exit for
Range("K" & i).Resize(1, 8).Value = _
myRange.Cells(i,1).Resize(1,8).Value
end if
Next

--
Regards,
Tom Ogilvy




"Michael168 " wrote in message
...
Hi! Tom Ogilvy,

Thanks for the code. Yes,it works perfectly.

One more question.

My module works from bottom up. Columns "K" to "R" store numeric
values.
How do I add in one condition to check for column "K"? When the code
encounters column "K" I want it to check if column "K" is empty. If it
is not empty ,I want it to exit the sub and give a message "Done"
otherwise keep processing until column "K" is not empty.

Regards,
Michael

Tom Ogilvy wrote:
*Without knowing what your sheet looks like

if isempty(Range("K" & myRow)) then
Range("K" & myRow).Value = myRange.Cells(i,j).Value
Range("L" & myRow).Resize(1,7).ClearContents
else
Range("IV" & myRow).End(xlToLeft)(1, 2).Value = _
myRange.Cells(i, j).Value
End if

this should work if it was going farther to the left than column K.

--
Regards,
Tom Ogilvy


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

The code don't work right. It start at col "K" but stop writing

the
other values to the other columns.

Range("IV" & myRow).End(xlToLeft)(1, 2).Value = _
myRange.Cells(i, j).Value

The above code is working except it always start next to empty

cell.
What I want how to specify it to start in col "K". The rest remain
unchange.

I even change the code to

Range("K" & myRow).End(xlToLeft)(1, 2).Value = _
myRange.Cells(i, j).Value

This also don't work. It still start next to the first empty cell.

I
actually need it to write in the values from Col "K" to Col "R".

Regards,
Michael


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



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