ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   function call paramater question (https://www.excelbanter.com/excel-programming/373533-function-call-paramater-question.html)

Arnold Klapheck

function call paramater question
 
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]))

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

Tom Ogilvy

function call paramater question
 
first, drop the square brackets. they add nothing but extra work.
You could change your function to accept a range.

or you could do

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


--
Regards,
Tom Ogilvy

"Arnold Klapheck" wrote:

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]))

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


Arnold Klapheck

function call paramater question
 
This returns the cell reference, in this case B2, what I want is the value in
the cell, AL, a string. any ideas?

"Tom Ogilvy" wrote:

you could do

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



Tom Ogilvy

function call paramater question
 
Dim intMaterial As Integer
intMaterial = ConvertMaterial(ActiveCell.Offset(0, -15).Value)


then

--
Regards,
Tom Ogilvy


"Arnold Klapheck" wrote:

This returns the cell reference, in this case B2, what I want is the value in
the cell, AL, a string. any ideas?

"Tom Ogilvy" wrote:

you could do

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




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

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