SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual 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 ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old October 12th, 2004, 11:04 PM
Jasdeep Jasdeep is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 Jasdeep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Linking Excel and VB

I have data (numbers in tabular form in an excel sheet. I want VBA to pick these numbers from Excel and use them as coefficients of an equation. This equation has to be displayed in a text file.
Example:
Data in Excel sheet:
2 5 6
3 6 9
4 9 7

To be displayed in equation form in the text file:
2a + 5b + 6c + 3d + 6e + 9f + 4g + 9h + 7i = Z

I would be greatful if somebody can write a code for this problem.
Thanks,
Jasdeep

Reply With Quote
  #2  
Old October 26th, 2004, 07:25 PM
KenVandergriff KenVandergriff is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 23 KenVandergriff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 8 sec
Reputation Power: 0
Red face

put the following VBA code into a module in your excel file:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/26/2004 by User
'

'
Dim a
a = Sheet1.Cells(1, 2) & "a +" & Sheet1.Cells(1, 3) & "b +"

Open "c:\TESTFILE.text" For Output As #1
Print #1, a

Close #1


End Sub

This shows the principle involved in addressing the individual cells of the spreadsheet (Sheet1) and how to open a text file, write to it then close it. There are probably more elegant ways to do this but this did work when I tried it. Maybe this will get you started.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Linking Excel and VB


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 | 
  
 

Iron Speed




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