Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A simple 'If...Then...' code needed?

Please can somebody help?

I want to run a macro which goes to cell a1 and if it is not blank to
copy that cells value into another cell (b1) and print the sheet. I
want then for the macro to move down to the next non-blank cell in
column A and do the same until it's visited all non-blank cells in the
range a1:a50.

I've been struggling with this for days and spent hours seaching the
net, but just can't find an answer.

Thanks in anticipation!!


__________________
Big Chris



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default A simple 'If...Then...' code needed?

try this

Sub printem()
For Each c In [d1:d6]
If Len(c) 0 Then
[b10] = c
ActiveSheet.PrintPreview
End If
Next c
End Sub

"Big Chris" wrote in message
...
Please can somebody help?

I want to run a macro which goes to cell a1 and if it is not blank to
copy that cells value into another cell (b1) and print the sheet. I
want then for the macro to move down to the next non-blank cell in
column A and do the same until it's visited all non-blank cells in the
range a1:a50.

I've been struggling with this for days and spent hours seaching the
net, but just can't find an answer.

Thanks in anticipation!!


__________________
Big Chris



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default A simple 'If...Then...' code needed?

for each cell in Range("A1:A50").SpecialCells(xlConstants)
cell.offset(0,1).Value = cell.Value
cell.parent.Printout
Next

Assumes the cells have constant values in them. If they will be formulas
for each cell in Range("A1:A50").SpecialCells(xlformulas)
if Cell.Value < "" then
cell.offset(0,1).Value = cell.Value
cell.parent.Printout
End if
Next

--
Regards,
Tom Ogilvy


"Big Chris" wrote in message
...
Please can somebody help?

I want to run a macro which goes to cell a1 and if it is not blank to
copy that cells value into another cell (b1) and print the sheet. I
want then for the macro to move down to the next non-blank cell in
column A and do the same until it's visited all non-blank cells in the
range a1:a50.

I've been struggling with this for days and spent hours seaching the
net, but just can't find an answer.

Thanks in anticipation!!


__________________
Big Chris



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly 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
simple loop needed please Alan Excel Discussion (Misc queries) 1 May 5th 10 06:33 PM
Simple formula needed shane Excel Discussion (Misc queries) 5 October 18th 07 11:27 PM
Another simple formula needed Connie Martin Excel Worksheet Functions 6 May 25th 06 04:35 PM
Help needed in a simple task vmantrana Excel Discussion (Misc queries) 3 April 18th 06 12:57 AM
simple (i think) UDF debug help needed Adam Kroger Excel Discussion (Misc queries) 4 December 18th 05 08:11 PM


All times are GMT +1. The time now is 06:02 AM.

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"