+ Reply to Thread
Results 1 to 4 of 4

Using Address Function in VBA

Hybrid View

stevetalaga Using Address Function in VBA 12-14-2015, 10:24 PM
MarvinP Re: Using Address Function in... 12-14-2015, 11:17 PM
Norie Re: Using Address Function in... 12-15-2015, 02:11 AM
stevetalaga Re: Using Address Function in... 12-15-2015, 07:47 AM
  1. #1
    Registered User
    Join Date
    07-06-2015
    Location
    Manila, Philippines
    MS-Off Ver
    2013
    Posts
    7

    Using Address Function in VBA

    Question: Can the Address() function be used from within VBA?

    Part 1) I have a spreadsheet where I use the Address function as a part of a formula within a cell without a problem but when I try to repeat what the formula does in VBA I get a compile error stating "Sub or Function not defined".

    Here's an extract of my code:

    Dim strForecastEnd As String
    strForecastEnd = Address(17, 3)

    Part 2) I actually want to get the column value from another sheet by searching for a string within a row and using that column. This works by placing the following formula in a cell:

    =ADDRESS(17,MATCH('DATA SHEET'!C7,8:8,0))

    However when I try to use the same approach from within VBA I get a compile error stating "Expected: Expression" and the first quote mark before the sheet name is highlighted. Here's my code:

    Dim strForecastEnd As String
    strForecastEnd = ADDRESS(17,MATCH('DATA SHEET'!C7,8:8,0))

    I'm not sure if this function can't be used in VBA or if the syntax needs to be different. Any help would be greatly appreciated!
    Thanks

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,370

    Re: Using Address Function in VBA

    Hi Steve,

    In VBA my standard is using "Cell(r,c)" type of notation. So Cell(17,3) brings back the value or other stuff in row 17 column 3.

    Now it seems you want to grab something from your "Data Sheet". I'd create a new variable like "colDataSheet" and have it equal to your match function from above. Then I think you'd want Cell(17, colDataSheet).

    If Cell() doesn't work then you can use "Cell(17,3).Address" to return the text of the address, which will return $C$17
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Using Address Function in VBA

    Try this.
    Dim strForecastEnd As String 
    strForecastEnd = Cells(17, Application.Match(Sheets("DATA SHEET").Range("C7").Value ,Range("8:8"),0)).Address
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    07-06-2015
    Location
    Manila, Philippines
    MS-Off Ver
    2013
    Posts
    7

    Re: Using Address Function in VBA

    Thanks Marvin and Norie - A great help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Adding Address function into another function
    By crgannon in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-25-2015, 02:14 PM
  2. Replies: 1
    Last Post: 06-02-2015, 01:38 AM
  3. [SOLVED] Using Address Function to create an address referencing the entire column
    By OliverS in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-28-2015, 01:06 AM
  4. [SOLVED] Replacing cell address in a formula with the result of ADDRESS function
    By CMG2 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-25-2014, 02:59 AM
  5. Address & Match function together (there may be an alternative function)
    By Sashulik in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2014, 05:39 AM
  6. [SOLVED] MATCH function workaround - nesting ADDRESS function?
    By BishBosh in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2013, 03:45 AM
  7. Use address function or other
    By Doug Laidlaw in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-24-2005, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1