Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2003, 06:57 PM
ckaren000 ckaren000 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 ckaren000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VBA- Open a file and manipluate cell

Hi people,
i am writing a simple macro in excel but i don't know what i am doin wrong.
here is the thing i wanted to do,
open a file (temp.xls) and manipluate some cell data. i created a button in a file and inputed following code
Private Sub CBopen_Click()
Workbooks.Open Filename:="C:\temp.xls"
Workbooks("temp.xls").Activate
Worksheets("sheet1").Activate
Range("E10").Select
ActiveCell.FormulaR1C1 = "=RC[-3]-5"
Range("F10").Select
ActiveCell.FormulaR1C1 = "=RC[-3]*100"
Range("E10:F10").Select
End Sub
but it gives error saying "select method of Range class failed" ( its giving error at "Range("E10").Select ").
i think i am not able to point excel to right workbook.
thanks in advance for the help.

Reply With Quote
  #2  
Old September 1st, 2003, 05:30 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I'm not sure why the range select method doesn't work (for some reason it's not activating the new spreedsheet).

this does work (takes a bit longer 2 code, but it's faster 2 run as well)

Code:
Workbooks.Open Filename:="C:\temp.xls"
Workbooks("temp.xls").Worksheets("sheet1").Range("E10").FormulaR1C1 = "=RC[-3]-5"
Workbooks("temp.xls").Worksheets("sheet1").Range("F10").FormulaR1C1 = "=RC[-3]*100"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VBA- Open a file and manipluate cell


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway