PDA

View Full Version : Solved: Range select error



Dipwad
03-02-2008, 06:59 AM
I know that this is a really simple issue with most of you, but I know very little about VB.
All I am trying to do is copy cells from one worksheet to another and run a couple sub routines. I used the "record new macro" function to get this far.
Here is the code:

Private Sub CommandButton1_Click()
'
' Don Macro
' Macro recorded 3/1/2008 by Don Roberts
'

'
Sheets("Don").Select
Application.Run "'Old Fart calculator.xls'!post"
Sheets("overview ").Select
Range("M10:Q10").Select
Selection.Copy
Sheets("Don").Select
Range("A2").Select
ActiveSheet.Paste
Range("H19").Select
Application.Run "'Old Fart calculator.xls'!figure"
Sheets("overview ").Select
Range("S10").Select
End Sub

When it gets to Range("A2").Select it stops at that point.
Hopefully someone can enlighten me as to why it stops and how to fix it.

Thanks

Bob Phillips
03-02-2008, 07:04 AM
Nothing obvious to me.

SDoes this work?



Private Sub CommandButton1_Click()

Application.Run "'Old Fart calculator.xls'!post"
Worksheets("overview ").Range("M10:Q10").Copy Worksheets("Don").Range("A2")
Application.Run "'Old Fart calculator.xls'!figure"
Worksheets("overview ").Select
Range("S10").Select
End Sub


BTW, is this workbook 'Old Fart calculator'? If so, there is no need for Application.Run

Dipwad
03-02-2008, 07:15 AM
I had to add this line - Sheets("Don").Select - Then it worked.

Thanks a bunch!

Norie
03-02-2008, 08:17 AM
You shouldn't need to select anything.

Private Sub CommandButton1_Click()
Application.Run "'Old Fart calculator.xls'!post"

Sheets("overview ").Range("M10:Q10").Copy Sheets("Don").Range("A2")

Application.Run "'Old Fart calculator.xls'!figure"
End Sub
Try that, but it still might not work.

Hard to tell with out seeing the code for the other 2 subs and/or an explanation of what you are trying to do.