Extracting first (cell)adress in VBA from string

Willem!

Board Regular
Joined
Mar 6, 2009
Messages
139
Hi!

I want to extract the first (cell)adress from a string (which is the string of a range) in VBA.

Example:

strRange = "$P$2:$T$4"

strCell = *some function/code* = "$P$2"

Can this be done in a simple way?

TIA
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

How would the "$P$2:$T$4" string be assigned to your strRange variable in the actual code? Using the range object's address property? What do you want to do with the first cell's address once you have it?
 
Upvote 0
Code:
strCell = Split(strRange, ":")(0)
would work.
 
Upvote 0
Hi,

How would the "$P$2:$T$4" string be assigned to your strRange variable in the actual code? Using the range object's address property? What do you want to do with the first cell's address once you have it?


Hi Colin, yes, I by using the object's address property I assign a value to strRange

On my sheet a user can select with a RefEdit-control a certain range from which I need the upperleft-, and the lowerright-corner. I need these for a VBA-function which creates a giant matrix (since my matrix has more than 73 variables I cannot use array-functions, so I need UDF's).

Thanx for your help! :)
 
Upvote 0

Forum statistics

Threads
1,222,142
Messages
6,164,169
Members
451,880
Latest member
2da

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top