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:
[TABLE="width: 80"]
<tbody>[TR]
[TD]$B$896[/TD]
[/TR]
[TR]
[TD]$F$994[/TD]
[/TR]
[TR]
[TD]$N$103[/TD]
[/TR]
[TR]
[TD]$V$961[/TD]
[/TR]
[TR]
[TD]$AH$509[/TD]
[/TR]
[TR]
[TD]$AX$222[/TD]
[/TR]
[TR]
[TD]$BB$1050[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
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,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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