Compile Error: Invalid Character

Heli_Guy

New Member
Joined
Jul 31, 2015
Messages
6
Hello,

Trying to write some macros, the first one clears a range when clicking a button.
The other one is supposed to scan a cel range for parsing purposes.

I'm stuck on both, getting "Compile Error: Invalid Character" and don't understand why. I highlighted the problematic rows below in red.
Any assistance would be greatly appreciated.

---------------------------------------------------------------------------------------------
Sub Clear_NOTAM()
Dim NOTAMSheet As Worksheet
Dim LastNOTAMRow As Integer


Set NOTAMSheet = Worksheets("Copy Paste NOTAM")
LastNOTAMRow = NOTAMSheet.UsedRange.Rows(NOTAMSheet.UsedRange.Rows.Count).Row


Worksheets("Copy Paste NOTAM").Range("A1:B" & str(LastNOTAMRow )).Value = ""


End Sub
---------------------------------------------------------------------------------------------
Sub Reformat_NOTAM()
Dim NOTAMSheet As Worksheet
Dim LastNOTAMRow As Integer
Dim NOTAMInputRange As Range
Dim RowIdx As Integer
Dim ColIdx As Integer
Dim CellValue As String


Set NOTAMSheet = Worksheets("Copy Paste NOTAM")
LastNOTAMRow = NOTAMSheet.UsedRange.Rows(NOTAMSheet.UsedRange.Rows.Count).Row 'Find last row

for RowIdx = 1 to LastNOTAMRow



End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
step thru your code and check the value of LastNOTAMRow
if it is empty or 0 that is your problem
 
Upvote 0
Your code has an extra character in each of your highlighted lines which doesn't show up when copied and pasted here.

The first line
Worksheets("Copy Paste NOTAM").Range("A1:B" & str(LastNOTAMRowhere)).Value = ""

The second line
for RowIdx = 1 to LastNOTAMRowhere

Copy and paste those lines into a cell as text and then run this code, you'll see.
Code:
Sub CheckOfCharacters()
    Dim i As Integer
    Dim str As String

str = ActiveCell.Value

For i = 1 To Len(str)
    Debug.Print Mid(str, i, 1) & "  =  " & Asc(Mid(str, i, 1))
Next

End Sub
 
Upvote 0
Thanks NoSparks. I was going nuts with this one!

It' very odd. Why wouldn't it show up? And where would it come from?

Thank you!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,311
Messages
6,171,347
Members
452,397
Latest member
ddneptune

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