ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A simple 'If...Then...' code needed? (https://www.excelbanter.com/excel-programming/279069-simple-if-then-code-needed.html)

Big Chris[_7_]

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/


Don Guillett[_4_]

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/




Tom Ogilvy

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/





All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com