Help with automating Application.GoTo fuction.

RagingR12

New Member
Joined
Sep 17, 2018
Messages
18
Hello! I usually come here for help when I can't find what I'm looking for, so maybe someone can help me.

I have a column with cell address:
$B$896
$F$994
$N$103
$V$961
$AH$509
$AX$222
$BB$1050

<tbody>
</tbody>

Now wat I want, is to go automatically trough the list, and place a * in the given cell address.
But I can’t make it work with Application.GoTo function in VBA

De addresse are in the same work sheet.

Thanks for any help.
 

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)
Here it is:

Code:
Sub Cell_Loop()


Dim cell As Range


'Loop through each cell in a cell range
  For Each cell In ActiveSheet.Range("GO2:GO4")


    Application.Goto Reference:= ???????
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "*"


  Next cell
  
End Sub
 
Upvote 0
Hi

You can use:

Code:
Sub Cell_Loop()


Dim cell As Range


'Loop through each cell in a cell range
  For Each cell In ActiveSheet.Range("GO2:GO4")

    Application.Goto Reference:=cell
    Application.CutCopyMode = False
    ActiveCell.Value = "*"

  Next cell
  
End Sub


Remark:
This does not make much sense, but I understand that this is part of some other code, and you may have your reasons to do it that way.

The usual way would be:

Code:
Sub Cell_Loop()

Range("GO2:GO4").Value = "*"
  
End Sub
 
Upvote 0
@ pgc01

No this is not wat I want.

I want to go to, "the given CELL address's in de Column" then go te these CELL ADDRESS's then place *. I want to do this for all given CELL adress in de column.

 
Upvote 0
@ pgc01

No this is not wat I want.

I want to go to, "the given CELL address's in de Column" then go te these CELL ADDRESS's then place *. I want to do this for all given CELL adress in de column.


Hi

Maybe I'm not understanding.

The first code I posted

- Goes to the cell GO2 and writes a "*" there

then

- Goes to the cell GO3 and writes a "*" there

then

- Goes to the cell GO3 and writes a "*" there

Is this not what you want?
 
Last edited:
Upvote 0
In CEL GO2 there is the value $B$896. I want to go to this cell address, place an *. then got to GO3 that has the value $F$994 and do the same.

I want to repeat this, until Colum "GO" comes to an empty cell, and then the loop is stops.
 
Upvote 0
I see

In that case you need

Code:
    Application.Goto Reference:=Range(cell.Value)
 
Upvote 0
Try this:

We do not need to use GOTO. This will do what you want.
Code:
Sub Goto_Me()
'Modified 3/7/2019 7:31:25 AM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "GO").End(xlUp).Row
Dim ans As String
    For i = 2 To Lastrow
        ans = Cells(i, "GO").Value
        Range(ans).Value = "*"
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
BTW, this is not the way you usually do it in vba, you don't go to the cell, you just reference it.

This is the usual way:

Code:
Sub Cell_Loop()
Dim cell As Range

'Loop through each cell in a cell range
  For Each cell In ActiveSheet.Range("GO2:GO4")

    Range(cell.Value).Value = "*"

  Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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