Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default getting runtime error

I am using VBA to format a workbook. Part of the formatting includes copying
a page and renaming it. This works fine. Then I return to original page to
add some formatting. This works fine. Then I am trying to return to the
second page and add some formatting. But I am getting a runtime error on the
first "range" line. The chart that I am trying to go to is the "Standard
Chart Data" page and I want to add text to D1.
Sheets("Standard Chart Data").Select
Range("D1").Select
ActiveCell.FormulaR1C1 = "Mean"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Plus 2sd"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Minus 2sd"
Range("I1").Select

Any ideas?
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default getting runtime error

I don't see anything obviously wrong with your code. I would point out
though that you can eliminate a lot of unneeded code and moving around like
this:

With Sheets("Standard Chart Data")
.Range("D1").Value = "Mean"
.Range("E1").Value = "Plus 2sd"
.Range("F1").Value = "Minus 2sd"
End With

This doesn't bother to select the sheet or any cells since it can directly
modify cells without it.
--
Jim Rech
Excel MVP

"Papa Jonah" wrote in message
...
|I am using VBA to format a workbook. Part of the formatting includes
copying
| a page and renaming it. This works fine. Then I return to original page
to
| add some formatting. This works fine. Then I am trying to return to the
| second page and add some formatting. But I am getting a runtime error on
the
| first "range" line. The chart that I am trying to go to is the "Standard
| Chart Data" page and I want to add text to D1.
| Sheets("Standard Chart Data").Select
| Range("D1").Select
| ActiveCell.FormulaR1C1 = "Mean"
| Range("E1").Select
| ActiveCell.FormulaR1C1 = "Plus 2sd"
| Range("F1").Select
| ActiveCell.FormulaR1C1 = "Minus 2sd"
| Range("I1").Select
|
| Any ideas?
| TIA


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default getting runtime error

That worked wonderfully. Thanks for helping me streamline my code.
I appreciate it very much.

"Jim Rech" wrote:

I don't see anything obviously wrong with your code. I would point out
though that you can eliminate a lot of unneeded code and moving around like
this:

With Sheets("Standard Chart Data")
.Range("D1").Value = "Mean"
.Range("E1").Value = "Plus 2sd"
.Range("F1").Value = "Minus 2sd"
End With

This doesn't bother to select the sheet or any cells since it can directly
modify cells without it.
--
Jim Rech
Excel MVP

"Papa Jonah" wrote in message
...
|I am using VBA to format a workbook. Part of the formatting includes
copying
| a page and renaming it. This works fine. Then I return to original page
to
| add some formatting. This works fine. Then I am trying to return to the
| second page and add some formatting. But I am getting a runtime error on
the
| first "range" line. The chart that I am trying to go to is the "Standard
| Chart Data" page and I want to add text to D1.
| Sheets("Standard Chart Data").Select
| Range("D1").Select
| ActiveCell.FormulaR1C1 = "Mean"
| Range("E1").Select
| ActiveCell.FormulaR1C1 = "Plus 2sd"
| Range("F1").Select
| ActiveCell.FormulaR1C1 = "Minus 2sd"
| Range("I1").Select
|
| Any ideas?
| TIA



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
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


All times are GMT +1. The time now is 11:14 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"