ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sending parameter of another cell value (https://www.excelbanter.com/excel-programming/373543-sending-parameter-another-cell-value.html)

Arnold Klapheck

sending parameter of another cell value
 
currently am using code:

Dim intMaterial As Integer
Dim strMaterial As String
strMaterial = ActiveCell.Offset([0], [-15])
intMaterial = ConvertMaterial(strMaterial)

the above works, but was going to try to reduce by two lines to:

Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15)) 'runtime error
1004 object defined error
-or-
Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15).Address(0,0))
'returns cell reference, not value
-or-
Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15).value) 'runtime
error 1004 object defined error

ConvertMaterial is my own function that takes in a string and returns an int.
Any ideas how to do this? thanx

Arnold Klapheck

sending parameter of another cell value
 
Oops, this does work, I did not have my active cell set properly

Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15).value)

Arnold

Tom Ogilvy

sending parameter of another cell value
 
I had a vague rememberance of what I thought was your function (did you post
it some time ago?) and had the impression you were passing in an address
string - so I guess I didn't pay as close attention as I should have since
your code shows you were passing in the value.

Value would be the property to use as you have discovered.

--
Regards,
Tom Ogilvy


"Arnold Klapheck" wrote:

Oops, this does work, I did not have my active cell set properly

Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15).value)

Arnold



All times are GMT +1. The time now is 01:40 AM.

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