Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
PAssing Values to Excel
Private Sub cmdCalc_Click()
' check values are inputted If txtIK1.Text = "" Then MsgBox "Input Weekly Hour Rate " Exit Sub End If If txtIK2.Text = "" Then MsgBox "Input Weekly Hours" Exit Sub End If txtIK3.Text = Multiply(txtIK1.Text, txtIK2.Text) txtIK4.Text = Multiply(txtIK3.Text, 52) End Sub I use above to calculate values, then the SUB MAinExcelApp does its stuff. i.e. open excel app, create worksheet then poulate the rows and headers. FIne so far. I wish to achieve by running cmdCalc again another calculation, then pass the values into the"open worksheet" in rows below the "previous calculation" Hope this makes sense to you.. Kevan "Bob Phillips" wrote: Don't declare xlApp as a New Excel.Application , just Excel.Application. Then use GetObject to see if it is running, and CreateObject if it is not. Not really sure what you mean by point 2, but .Offset(1,0) takes you 1 row down. -- HTH RP (remove nothere from the email address if mailing direct) "Kevan Hughes" wrote in message ... I have created VB6 program and have used the following : Sub MainExcelApp() Dim xclApp As New Excel.Application Dim xclWorkbook As Excel.Workbook Dim xclSheetA As Excel.Worksheet Dim xclRangeA As Excel.Range Dim rng As Excel.Range ' Create the workbook and add a sheet Set xclWorkbook = xclApp.Workbooks.ADD Set xclSheetA = xclWorkbook.Worksheets(1) xclSheetA.Activate ' Name the sheet xclSheetA.Name = frmSjukMain.Caption ' Create the header row Set xclRangeA = xclSheetA.Range(xclSheetA.Cells(5, 2), xclSheetA.Cells(5, 7)) Set xclRangeA = xclSheetA.Range(xclSheetA.Cells(6, 2), xclSheetA.Cells(6, 7)) Set xclRangeA = xclSheetA.Range(xclSheetA.Cells(10, 2), xclSheetA.Cells(10, 7)) This is an excerpt of course. You can see I have a header column and then below it values being passed from a MDI form in my program. Final cell range is for a formula ( further down my coding..It works ) I would like to be able to achieve 2 things. 1. Detect that Excel is open, which it is after running the first instance and passed it values. I have verified it is still open. 2. Allow me to pass another calculation totals, using different values from the same MDI form, and passing these into the "active sheet" from 1st calculation, BUT in the columns&rows directly below 1st calculation. That is why i have an addition formula situated several rows below 1st calc. To ADD my Total costs.. I hope this is understandable to what I am trying to achieve thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
passing Excel system values (constant) of properties as arguments | Excel Programming | |||
Excel VBA - Problem calculating and passing values to another worksheet | Excel Programming | |||
Passing values to new app | Excel Programming | |||
Passing Values Syntax | Excel Programming | |||
Passing values between 2 subs ? | Excel Programming |