ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   **URGENT** Macro to find a Cell (https://www.excelbanter.com/excel-programming/416922-%2A%2Aurgent%2A%2A-macro-find-cell.html)

Lost

**URGENT** Macro to find a Cell
 
If I have the column row references given on 2 cells in my spreadsheet, I
need a macro to read the contents of the two cells and then select that
particular cell.

Here is the current code I have:

Sub test()

Sheets("Revised").Activate
ActiveSheet.Cells(1, 2).Select

End Sub

In the existing code the column/row references are static. Ideally I would
like the column/row references to be dependent on what figures are listed in
cells A1 & B1, however you cannot simply enter those in 1 & 2's spot or it
will error. Help!

JLGWhiz

**URGENT** Macro to find a Cell
 
Here is one way:

Dim x As Long
Dim y As long

x = Range("A1").Value
y = Range("B1").Value

Sheets("Revised").Activate
ActiveSheet.Cells(x, y).Select

"Lost" wrote:

If I have the column row references given on 2 cells in my spreadsheet, I
need a macro to read the contents of the two cells and then select that
particular cell.

Here is the current code I have:

Sub test()

Sheets("Revised").Activate
ActiveSheet.Cells(1, 2).Select

End Sub

In the existing code the column/row references are static. Ideally I would
like the column/row references to be dependent on what figures are listed in
cells A1 & B1, however you cannot simply enter those in 1 & 2's spot or it
will error. Help!


Jim Thomlinson

**URGENT** Macro to find a Cell
 
I would be inclined to leave Y as being of type variant. That way the user
can enter either a column letter or number as needed...
--
HTH...

Jim Thomlinson


"JLGWhiz" wrote:

Here is one way:

Dim x As Long
Dim y As long

x = Range("A1").Value
y = Range("B1").Value

Sheets("Revised").Activate
ActiveSheet.Cells(x, y).Select

"Lost" wrote:

If I have the column row references given on 2 cells in my spreadsheet, I
need a macro to read the contents of the two cells and then select that
particular cell.

Here is the current code I have:

Sub test()

Sheets("Revised").Activate
ActiveSheet.Cells(1, 2).Select

End Sub

In the existing code the column/row references are static. Ideally I would
like the column/row references to be dependent on what figures are listed in
cells A1 & B1, however you cannot simply enter those in 1 & 2's spot or it
will error. Help!


JLGWhiz

**URGENT** Macro to find a Cell
 
Hi Jim, That's true. I just looked at the syntax the OP used and went with
that. I don't even know which cells were to be used for row or column, but
thought I would at least get them pointed in the right direction.

"Jim Thomlinson" wrote:

I would be inclined to leave Y as being of type variant. That way the user
can enter either a column letter or number as needed...
--
HTH...

Jim Thomlinson


"JLGWhiz" wrote:

Here is one way:

Dim x As Long
Dim y As long

x = Range("A1").Value
y = Range("B1").Value

Sheets("Revised").Activate
ActiveSheet.Cells(x, y).Select

"Lost" wrote:

If I have the column row references given on 2 cells in my spreadsheet, I
need a macro to read the contents of the two cells and then select that
particular cell.

Here is the current code I have:

Sub test()

Sheets("Revised").Activate
ActiveSheet.Cells(1, 2).Select

End Sub

In the existing code the column/row references are static. Ideally I would
like the column/row references to be dependent on what figures are listed in
cells A1 & B1, however you cannot simply enter those in 1 & 2's spot or it
will error. Help!



All times are GMT +1. The time now is 07:02 PM.

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