Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default if then else

Ok I'm not a VB programer.

However what I'm trying to do is copy a variable starting in cell A4 to D3
and then print (preview in this example) a report. Next the macro moves to
A5, copies the value in D3 and previews a report. Next the macro moves to
A6, copies the value in D3 and previews the report. Ok, I'm sure I'm
insulting you right now.

I have add "If Applicaition.ActiveCell = False Then Exit Sub" to stop
previewing the report when there is no longer a value in A6, A7, etc.

This approach is not very efficient because I don't know how to loop the
macro to to move down a cell, I'm actually typing the cell references in the
macro "R4C1", R5C1, etc. I'm sure this humoring you, but this is my 1st
attempt at this.

See below:

Application.Goto Reference:="R4C1"
If Application.ActiveCell = False Then Exit Sub
Application.CutCopyMode = False
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R5C1"
If Application.ActiveCell = False Then Exit Sub
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R6C1"
If Application.ActiveCell = False Then Exit Sub
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R7C1"
If Application.ActiveCell = False Then Exit Sub




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default if then else

hi
if i understand you, this might be what your want....
Sub movedown()
Dim d As Range
Dim lr As Long
Set d = Range("D3")
'change the print area to suit your data
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$14"
'find the last row in column A
lr = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("A4:A" & lr)
d = cell.Value
'change the sheet name to suit
Worksheets("Sheet1").PrintPreview
Next cell
End Sub

Regards
FSt1

"JeffH" wrote:

Ok I'm not a VB programer.

However what I'm trying to do is copy a variable starting in cell A4 to D3
and then print (preview in this example) a report. Next the macro moves to
A5, copies the value in D3 and previews a report. Next the macro moves to
A6, copies the value in D3 and previews the report. Ok, I'm sure I'm
insulting you right now.

I have add "If Applicaition.ActiveCell = False Then Exit Sub" to stop
previewing the report when there is no longer a value in A6, A7, etc.

This approach is not very efficient because I don't know how to loop the
macro to to move down a cell, I'm actually typing the cell references in the
macro "R4C1", R5C1, etc. I'm sure this humoring you, but this is my 1st
attempt at this.

See below:

Application.Goto Reference:="R4C1"
If Application.ActiveCell = False Then Exit Sub
Application.CutCopyMode = False
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R5C1"
If Application.ActiveCell = False Then Exit Sub
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R6C1"
If Application.ActiveCell = False Then Exit Sub
Selection.Copy
Range("D3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
Application.Goto Reference:="R7C1"
If Application.ActiveCell = False Then Exit Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if then else

For Each cell In Range("A4:A" & lr)
d = cell.Value
'change the sheet name to suit
Worksheets("Sheet1").PrintPreview
Next cell


Or, alternately, for the loop above, this looping method...

For x = 4 To lr
d.Value = Cells(x, "A").Value
'change the sheet name to suit
Worksheets("Sheet1").PrintPreview
Next

Rick
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



All times are GMT +1. The time now is 08:35 PM.

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"