Skip to main content
deleted 98 characters in body
Source Link
Alex K.
  • 176.8k
  • 32
  • 276
  • 299

Basically I have a function which searches a certain worksheet for the title of a column, and then returns the column number.

I also need another function which searches this column for a specified value. It would be neat for me to combine the two, but I'm not sure how to express the range to search in using the column number.

An outline of my code is below; there's not really much to say, I just don't know what to put in the Range bit

Cheers!

Function getValue(...parameters...) As Double col = getColumnNumber(worksheetName, columnTitle) 'get column number With Worksheets(worksheetName).Range(****) ...conditions for which value End With End Function

Function getValue(...parameters...) As Double col = getColumnNumber(worksheetName, columnTitle) 'get column number With Worksheets(worksheetName).Range(****) ...conditions for which value End With End Function 

Basically I have a function which searches a certain worksheet for the title of a column, and then returns the column number.

I also need another function which searches this column for a specified value. It would be neat for me to combine the two, but I'm not sure how to express the range to search in using the column number.

An outline of my code is below; there's not really much to say, I just don't know what to put in the Range bit

Cheers!

Function getValue(...parameters...) As Double col = getColumnNumber(worksheetName, columnTitle) 'get column number With Worksheets(worksheetName).Range(****) ...conditions for which value End With End Function

Basically I have a function which searches a certain worksheet for the title of a column, and then returns the column number.

I also need another function which searches this column for a specified value. It would be neat for me to combine the two, but I'm not sure how to express the range to search in using the column number.

An outline of my code is below; there's not really much to say, I just don't know what to put in the Range bit

Cheers!

Function getValue(...parameters...) As Double col = getColumnNumber(worksheetName, columnTitle) 'get column number With Worksheets(worksheetName).Range(****) ...conditions for which value End With End Function 
Source Link

Searching column defined by number VBA

Basically I have a function which searches a certain worksheet for the title of a column, and then returns the column number.

I also need another function which searches this column for a specified value. It would be neat for me to combine the two, but I'm not sure how to express the range to search in using the column number.

An outline of my code is below; there's not really much to say, I just don't know what to put in the Range bit

Cheers!

Function getValue(...parameters...) As Double col = getColumnNumber(worksheetName, columnTitle) 'get column number With Worksheets(worksheetName).Range(****) ...conditions for which value End With End Function