Hello,
How do I write code to move on to another question if the information doesn't exist on my spreadsheet? My code is:
'Select Start of range
Range("B1").Select
While ActiveCell.Value <> ""
'This writes 'Cash' in column A against cash transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "Cash"
ActiveCell.Offset(1, 0).Select
Wend
'Select Start of range
Columns("B:B").Select
Selection.Find(What:="Cheque", After:=Range("B1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Select
While ActiveCell.Value <> ""
'This writes 'Cheque' in column A against cheque transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "Cheque"
ActiveCell.Offset(1, 0).Select
Wend
'Select Start of range
Columns("B:B").Select
Selection.Find(What:="EFT", After:=Range("B1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Select
While ActiveCell.Value <> ""
'This writes 'EFT' in column A against EFT transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "EFT"
ActiveCell.Offset(1, 0).Select
Wend
The highlighted area in blue above comes back with a run-time error '91': Object variable or With block variable not set.
I hope you can help me move on to my next search criteria. There will be a number of times when Cheques will not exist on the report and maybe EFT from time to time, although rare.
Best wishes,
Peggy
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Cash[/TD]
[TD]Cash[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Cash[/TD]
[TD]Stationery[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Cash[/TD]
[TD]Cards[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]EFT[/TD]
[TD]EFT[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]EFT[/TD]
[TD]Cards[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]EFT[/TD]
[TD]Calendars[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]EFT[/TD]
[TD]Pencils[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
How do I write code to move on to another question if the information doesn't exist on my spreadsheet? My code is:
'Select Start of range
Range("B1").Select
While ActiveCell.Value <> ""
'This writes 'Cash' in column A against cash transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "Cash"
ActiveCell.Offset(1, 0).Select
Wend
'Select Start of range
Columns("B:B").Select
Selection.Find(What:="Cheque", After:=Range("B1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Select
While ActiveCell.Value <> ""
'This writes 'Cheque' in column A against cheque transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "Cheque"
ActiveCell.Offset(1, 0).Select
Wend
'Select Start of range
Columns("B:B").Select
Selection.Find(What:="EFT", After:=Range("B1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Select
While ActiveCell.Value <> ""
'This writes 'EFT' in column A against EFT transactions.
If ActiveCell.Value <> "" Then ActiveCell.Offset(0, -1).Value = "EFT"
ActiveCell.Offset(1, 0).Select
Wend
The highlighted area in blue above comes back with a run-time error '91': Object variable or With block variable not set.
I hope you can help me move on to my next search criteria. There will be a number of times when Cheques will not exist on the report and maybe EFT from time to time, although rare.
Best wishes,
Peggy
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Cash[/TD]
[TD]Cash[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Cash[/TD]
[TD]Stationery[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Cash[/TD]
[TD]Cards[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]EFT[/TD]
[TD]EFT[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]EFT[/TD]
[TD]Cards[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]EFT[/TD]
[TD]Calendars[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]EFT[/TD]
[TD]Pencils[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]