ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Send values to "calculator" and answer back (https://www.excelbanter.com/excel-programming/304339-send-values-calculator-answer-back.html)

Howard

Send values to "calculator" and answer back
 
I have a spreadsheet with many rows and columns in it. I
would like to send values from 4 cell to a "calculator" on
another work sheet. I then want to return the calculated
value back to the original worksheet. Then go down to the
next row and repeat the process. I can do it with a macro
but I have 1300 rows and it will get very tedious. Is
there a FUNCTION that will send the value?
Thank you
Howard

Dave Peterson[_3_]

Send values to "calculator" and answer back
 
I used the four cells in columns A:D and sent them to a second worksheet
(somewhere!).

Then returned a single cell into column E of the same row:

Option Explicit
Sub testme()

Dim InputWks As Worksheet
Dim CalcWks As Worksheet
Dim myRng As Range
Dim myCell As Range

Set InputWks = Worksheets("sheet1")
Set CalcWks = Worksheets("sheet2")

With InputWks
'headers in row 1
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

With CalcWks
For Each myCell In myRng.Cells
.Range("a1").Value = myCell.Value
.Range("b3").Value = myCell.Offset(0, 1).Value
.Range("c9").Value = myCell.Offset(0, 2).Value
.Range("e99").Value = myCell.Offset(0, 3).Value
Application.Calculate
myCell.Offset(0, 4).Value = .Range("z1").Value
Next myCell
End With

End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Howard wrote:

I have a spreadsheet with many rows and columns in it. I
would like to send values from 4 cell to a "calculator" on
another work sheet. I then want to return the calculated
value back to the original worksheet. Then go down to the
next row and repeat the process. I can do it with a macro
but I have 1300 rows and it will get very tedious. Is
there a FUNCTION that will send the value?
Thank you
Howard


--

Dave Peterson



All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com