Trying to figure out how to use VBA Goto

SacredHeartMission

New Member
Joined
Nov 22, 2017
Messages
9
I have no experience with VBA Goto although it seems like this is my only option.

I am trying to use a series of cell addresses to enter a value "RTS" in the cell next to the cell addresses.

I was wondering how I can achieve this.

Thanks in advance
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I.e.
[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]$D$8061[/TD]
[/TR]
[TR]
[TD="class: xl63"]-> E8061 ="RTS"[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Sub ColorCells()
Dim i As Long


For i = 2 To Range("O65536").End(xlUp).Row
Range(Cells(i, 15).Value).Interior.ColorIndex = 3
Next i
End Sub

I used this formula from another thread to try, can anyone explain what is wrong with the formula?

My cell address data was created using cell(address) function and is in column O.
 
Upvote 0
Your subject title says trying to use Goto.

But your question says nothing about Goto

Tell us what your wanting to do.
 
Upvote 0
Is this what you want.
Colors all cells in column "O" with values.

Code:
Sub ColorCells()
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "O").End(xlUp).Row
    For i = 2 To Lastrow
        Cells(i, 15).Interior.ColorIndex = 3
    Next i
End Sub
 
Upvote 0
My mistake, I am a complete novice with VBA.

I am attempting to match physical hardcopies of names to an excel data set to assess which ones are in the data set, and then either change the colour of the cell or or enter into the cell next to it "RTS", whichever is easier.

So for "John Smith" I used a vlookup function to first determine if he was in the data set, and then I determined the cell addresses using CELL(address) which are in column O. "John Smith" cell address = $D$500

From a thread I found the formula they used (adapted to suit my columns)

Sub ColorCells()
Dim i As Long


For i = 2 To Range("O65536").End(xlUp).Row
Range(Cells(i, 15).Value).Interior.ColorIndex = 3
Next i
End Sub

However it comes up with the error "Runtime error 1004 Method "Range of object"_Global failed

If you could help me with either another route or a corrected formula that would be great!
 
Upvote 0
So you want to search column "O" for this name
Where is this: physical hardcopies of names:

Where on the sheet is this list of names like "John Smith" and then "Jane Doe"
 
Upvote 0
Your script appears to be searching column(15) which is column"O"
But now it looks likes you want to search column "D"
 
Upvote 0
So the dataset of names is in column D
The vlookup is in column M
The data set im using the match the two is in column n
the cell addresses are in column O

I want to use the cell addresses of the names that have matched and colour them

Does this make more sense? Thanks again!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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