Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Storing cell location

Okay, heres one I just can't seem to think out. I have a cell that
contains the following:
=$D$245+$D$600

I want to be able to store each cell to a variable. Is there anyway
for me to split and store the cells? The cell numbers change
frequently and can be as small as a single digit or as big as 4 digits.
Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Storing cell location

Here's what I came up with:

Sub test()

Dim cell_formula As String, first_address As String, second_address As
String
Dim plus_location As Long
Dim first_cell As Range, second_cell As Range

With Sheet1.Range("A1")
cell_formula = CStr(.Formula)
plus_location = InStr(2, cell_formula, "+")
first_address = Mid$(cell_formula, 2, plus_location - 2)
second_address = Mid$(cell_formula, plus_location + 1)
Set first_cell = ActiveSheet.Range(first_address)
Set second_cell = ActiveSheet.Range(second_address)
End With

End Sub

hth,

Doug

"NacellesEng" wrote in message
oups.com...
Okay, heres one I just can't seem to think out. I have a cell that
contains the following:
=$D$245+$D$600

I want to be able to store each cell to a variable. Is there anyway
for me to split and store the cells? The cell numbers change
frequently and can be as small as a single digit or as big as 4 digits.
Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Storing cell location

I went in two directions concerning which sheet you were working with. This
assumes the formula is in range A1 and deals with the ActiveSheet
throughout:

Sub test()

Dim cell_formula As String, first_address As String, second_address As
String
Dim plus_location As Long
Dim first_cell As Range, second_cell As Range

With ActiveSheet
cell_formula = CStr(.Range("A1").Formula)
plus_location = InStr(2, cell_formula, "+")
first_address = Mid$(cell_formula, 2, plus_location - 2)
second_address = Mid$(cell_formula, plus_location + 1)
Set first_cell = .Range(first_address)
Set second_cell = .Range(second_address)
first_cell.Select
End With

End Sub

"Doug Glancy" wrote in message
...
Here's what I came up with:

Sub test()

Dim cell_formula As String, first_address As String, second_address As
String
Dim plus_location As Long
Dim first_cell As Range, second_cell As Range

With Sheet1.Range("A1")
cell_formula = CStr(.Formula)
plus_location = InStr(2, cell_formula, "+")
first_address = Mid$(cell_formula, 2, plus_location - 2)
second_address = Mid$(cell_formula, plus_location + 1)
Set first_cell = ActiveSheet.Range(first_address)
Set second_cell = ActiveSheet.Range(second_address)
End With

End Sub

hth,

Doug

"NacellesEng" wrote in message
oups.com...
Okay, heres one I just can't seem to think out. I have a cell that
contains the following:
=$D$245+$D$600

I want to be able to store each cell to a variable. Is there anyway
for me to split and store the cells? The cell numbers change
frequently and can be as small as a single digit or as big as 4 digits.
Thanks!





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing formula in cell Cinco Excel Discussion (Misc queries) 14 July 26th 09 10:34 PM
Storing an array in a cell Blue Max Excel Worksheet Functions 9 March 18th 09 12:54 PM
Storing value in a variable from a cell Saadi Excel Programming 6 January 8th 05 01:27 PM
Storing additonal information for a cell Peter[_44_] Excel Programming 2 August 4th 04 07:48 AM
Storing Cell Values in Access Mick Excel Programming 2 July 11th 04 09:34 AM


All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"