ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use a cell value to point to desired location. (https://www.excelbanter.com/excel-programming/353574-use-cell-value-point-desired-location.html)

GeneWan

Use a cell value to point to desired location.
 
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?

Ardus Petus

Use a cell value to point to desired location.
 

"GeneWan" a écrit dans le message de
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the

value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?


See attached file: http://cjoint.com/?creRs6Unma



GeneWan

Use a cell value to point to desired location.
 
Thanks Ardus,

that is exactly what I am looking for! But how can I access the macro?

"Ardus Petus" wrote:


"GeneWan" a écrit dans le message de
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the

value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?


See attached file: http://cjoint.com/?creRs6Unma




GeneWan

Use a cell value to point to desired location.
 
Hi Ardus,

I managed to locate the code under "Feuil1 (Feuil1)", as far as I would like
to, for now, my understanding is limited to codes run under "Modules". As I
am still familliarizing myself with VBA. Hence appreciate if you could
translate it under "Modules" if it's not too much trouble?

"Ardus Petus" wrote:


"GeneWan" a écrit dans le message de
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the

value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?


See attached file: http://cjoint.com/?creRs6Unma




Norman Jones

Use a cell value to point to desired location.
 
Hi Gene,

For scenario1, try:

'=============
Public Sub TesterA()
Dim Rng1 As range, rng2 As range
Dim arr As Variant

Set Rng1 = range("A1")
Set rng2 = range("D1")

arr = Split(Rng1.Value, ",")

Cells(CLng(arr(1)), CLng(arr(0))).Value = rng2.Value

End Sub
'<<=============

For the second scenario, try:

'=============
Public Sub TesterB()
Dim Rng1 As range, rng2 As range, rng3 As range
Dim i As Long, j As Long

Set Rng1 = range("A1")
Set rng2 = range("B2")
Set rng3 = range("D1")

i = Rng1.Value
j = rng2.Value

Cells(j, i).Value = rng3.Value

End Sub
'<<=============


---
Regards,
Norman



"GeneWan" wrote in message
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the
value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?




Gary Keramidas

Use a cell value to point to desired location.
 
you could use something like this

sub test
Cells(Range("B2").Value, Range("A1").Value).Value = Range("D1").Value
end sub
--


Gary


"GeneWan" wrote in message
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?




GeneWan

Use a cell value to point to desired location.
 
Thanks Norman!

it works well and now I am looking to do this over a range... might be back
for more!

"Norman Jones" wrote:

Hi Gene,

For scenario1, try:

'=============
Public Sub TesterA()
Dim Rng1 As range, rng2 As range
Dim arr As Variant

Set Rng1 = range("A1")
Set rng2 = range("D1")

arr = Split(Rng1.Value, ",")

Cells(CLng(arr(1)), CLng(arr(0))).Value = rng2.Value

End Sub
'<<=============

For the second scenario, try:

'=============
Public Sub TesterB()
Dim Rng1 As range, rng2 As range, rng3 As range
Dim i As Long, j As Long

Set Rng1 = range("A1")
Set rng2 = range("B2")
Set rng3 = range("D1")

i = Rng1.Value
j = rng2.Value

Cells(j, i).Value = rng3.Value

End Sub
'<<=============


---
Regards,
Norman



"GeneWan" wrote in message
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the
value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?





GeneWan

Use a cell value to point to desired location.
 
Thanks Gary~

Sweet!

"Gary Keramidas" wrote:

you could use something like this

sub test
Cells(Range("B2").Value, Range("A1").Value).Value = Range("D1").Value
end sub
--


Gary


"GeneWan" wrote in message
...
scenario 1: say, if cell A1 contains the value 10,2 and cell D1 contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the value
8 in it? ie. use the values as an X,Y coordinate. Which would be the more
efficient way of doing it?





avveerkar[_62_]

Use a cell value to point to desired location.
 

GeneWan Wrote:
scenario 1: say, if cell A1 contains the value 10,2 and cell D1
contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the
value
8 in it? ie. use the values as an X,Y coordinate. Which would be the
more
efficient way of doing it?


scenario 1

ComPos=Instr(1,[a1],",") ' locate comma
X=Val(Left([a1],ComPos-1))
Y=Mid(([a1],ComPos+1,5))
Cells(Y,X)=[d1]

scenario 2

cells([b2],[[a1]).value=[d1]

A V Veerkar


--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=513481


GeneWan

Use a cell value to point to desired location.
 
Hi A,

Thanks, however, when I execute the line:
Y=Mid([a1],ComPos+1,5)

I encountered an "Type mismatched" error, any idea why?

"avveerkar" wrote:


GeneWan Wrote:
scenario 1: say, if cell A1 contains the value 10,2 and cell D1
contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the
value
8 in it? ie. use the values as an X,Y coordinate. Which would be the
more
efficient way of doing it?


scenario 1

ComPos=Instr(1,[a1],",") ' locate comma
X=Val(Left([a1],ComPos-1))
Y=Mid(([a1],ComPos+1,5))
Cells(Y,X)=[d1]

scenario 2

cells([b2],[[a1]).value=[d1]

A V Veerkar


--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=513481



GeneWan

Use a cell value to point to desired location.
 
Hi A,

I've decided to go with scenario 1, hence, assuming a1=10,2 could I do the
following? I'm a true amatuer to this, really do appreciate if you could
advise on the correct arguments that I should use..

ComPos = InStr(1, Cells([a], [b]), ",")
x = Val(Left((Cells([a], [b])), ComPos - 1))
y = Mid((Cells([a, b])), ComPos + 1, 5)
Cells(y, x) = [f2]


"avveerkar" wrote:


GeneWan Wrote:
scenario 1: say, if cell A1 contains the value 10,2 and cell D1
contains
value 8.

scenario 2: say, if cell A1=10, cell B2=2 and D1=8.

how can I write a macro to select the cell J2 (ie. 10,2) and place the
value
8 in it? ie. use the values as an X,Y coordinate. Which would be the
more
efficient way of doing it?


scenario 1

ComPos=Instr(1,[a1],",") ' locate comma
X=Val(Left([a1],ComPos-1))
Y=Mid(([a1],ComPos+1,5))
Cells(Y,X)=[d1]

scenario 2

cells([b2],[[a1]).value=[d1]

A V Veerkar


--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=513481




All times are GMT +1. The time now is 12:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com