Going to a cell reference

Duckmorph

New Member
Joined
Aug 2, 2013
Messages
25
Im trying to workout the cell refrence and then go to a cell a couple over and enter data

So far i have

x = Sheet4.Range("A1").formula

'which returns x as =Markets!F155

Now i have the problem, i want to use the row number (155) and go to column "Q" in "Markets" and enter some data but i cant seem to get there. I have been trying to get a split to work but with no success.

Any ideas?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello

This subtle piece of coding is all you need:

Code:
Sub Wigi()

    With Range(Mid(Sheet4.Cells(1).Formula, 2))
        .Offset(, 17 - .Column) = "new value"
    End With

End Sub
 
Upvote 0
Thanks Wigi for you reply,

Im getting an error still, maybe i didnt explain very well before.

Im trying to look at the formula in a cell, lets say......

Sheet4.Range("I7").Formula

This formula will return this "=Markets!F155"

And what im after doing is going to the "Q155" in the "Markets" sheet which is Sheet24

Then Inputing a new value.

Is that any better?

Cheers
 
Upvote 0
Thanks Wigi for you reply,

Im getting an error still, maybe i didnt explain very well before.

Im trying to look at the formula in a cell, lets say......

Sheet4.Range("I7").Formula

This formula will return this "=Markets!F155"

And what im after doing is going to the "Q155" in the "Markets" sheet which is Sheet24

Then Inputing a new value.

Is that any better?

Cheers


What my code does is exactly that...
It will put the text "New value" in the cell in Q155 on sheet Markets.
Did you try it? I set it up on my PC exactly as you described it, and tested it, so I'm quite sure this works :-)
What is the error you still get? On what line of code?
 
Upvote 0
Hey

Sorry Wigi yes this does work, my fault i'm new to this and should of posted originally exactly what i'm trying to do,

Im using a variable as well to locate the inital cell

the cell i want to access is

Dim prow As Integer

prow = MatchBox.Text + 4

With Range(Mid(Sheet4.Cells(prow, 9).Formula, 2))
.Offset(, 17 - .Column) = "New Value"
End With

But i get error in the red.

Any idea?

Cheers
 
Upvote 0
Ive narrowed it down a bit.

The problem im having is with the With Range(Mid(Sheet4.Cells(prow, 9).Formula, 2))

This is ok if its Range(Mid(Sheet4.Cells(1).Formula, 2)), but i need to be using the variable.

Cheers
 
Upvote 0
Try...

Rich (BB code):
prow = CLng(MatchBox.Text) + 4
With Range(Mid(Sheet4.Cells(prow, 9).Formula, 2))
 
Upvote 0
Hey

Im still getting the error, i cant seem to assign a variable in this spot, is the problem how im declaring the variable?

In this case prow = 7

so if i use With Range(Mid(Sheet4.Cells(7, 9).Formula, 2)) i still get an error
 
Upvote 0
What does this:

Rich (BB code):
Debug.Print Sheet4.Cells(7, 9).Formula

give you in the Immediate Window?
 
Upvote 0
I dont get anything....

if i replace the (1) with (7,9) or (prow, 9) i get a Run time error 1004, Method 'Range" of obeject'_Global" failed.

if i replace the (1) with a (2) the code works from "b1" but how come i cant input a row number in?
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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