ProphetofProfit
New Member
- Joined
- Feb 28, 2011
- Messages
- 28
First day of creating VBA code, been a lot of fun at times and a lot of pain too. Fortunately I found similar code to what I was looking to create, now it's a case of adjusting it, here's what I've got. There is an error where I've put a ''
Code:
Sub AELOv1()
Worksheets("GAMES").Activate
Application.ScreenUpdating = False
Row = 2
Column = 4
Start:
Worksheets("GAMES").Cells(Row, Column).Select
If ActiveCell.Value = "" Then GoTo Finish
'select home team
ActiveCell.Select
'search for home team in "teams"
Worksheets("TEAMS").Range("A2").Select
Do
If ActiveCell.Value = Range("A2") Then GoTo GetHomeData Else:
'work down table checking for team
ActiveCell.Offset(rowOffset:=1, columnoffset:=0).Activate
If ActiveCell.Value = "" Then GoTo Finish2
Loop
-------
What I aimed to do was find the value of a field in "GAMES" that corresponds to a team name. Then I'd go over to "TEAMS" and look up this team name in a column of teams, which starts at "A2". The Do-Loop is not my creation, but it should search through the fields from A2 downwards and stop when the right team is selected.
The error is
"Run-time error '1004': Select method of Range class failed."
Code:
Sub AELOv1()
Worksheets("GAMES").Activate
Application.ScreenUpdating = False
Row = 2
Column = 4
Start:
Worksheets("GAMES").Cells(Row, Column).Select
If ActiveCell.Value = "" Then GoTo Finish
'select home team
ActiveCell.Select
'search for home team in "teams"
Worksheets("TEAMS").Range("A2").Select
Do
If ActiveCell.Value = Range("A2") Then GoTo GetHomeData Else:
'work down table checking for team
ActiveCell.Offset(rowOffset:=1, columnoffset:=0).Activate
If ActiveCell.Value = "" Then GoTo Finish2
Loop
-------
What I aimed to do was find the value of a field in "GAMES" that corresponds to a team name. Then I'd go over to "TEAMS" and look up this team name in a column of teams, which starts at "A2". The Do-Loop is not my creation, but it should search through the fields from A2 downwards and stop when the right team is selected.
The error is
"Run-time error '1004': Select method of Range class failed."