VBA Code check

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Hi does any one know why this could does not work. I am not getting any errors, it does nothing when i run. I am trying to get the code to look in Col B for N/A, if found then let the user know why msgbox

Code:
Sub Test()
    Dim LR1 As Long
    
    LR1 = Range("C" & Rows.count).End(xlUp).Row
    
    If LR1 < 5 Then LR1 = 5
    If UCase$(Trim$(Sheets(1).Range("B" & LR1).Value)) = "N/A" Then
            MsgBox "There is a new a/c"
    End If

End Sub
 
I understand your need but do you have ALL the code available ....it might be easier if we view and edit the whole script in one hit.
It makes it easier for us AND you to understand !
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Short answer would be yes. If your code exits the macro when it finds a match, then it returns to the sub that called it. There's more than one way to write such an "early exit" - I think we've seen perhaps three variations on this theme already in this thread - I like the Exit For as soon as a match is found (thus no longer looping through the cells to try to find matches). Though Michael's version works well to count up the total number of new accounts and reporting 1 (or more) found.
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,246
Members
453,152
Latest member
ChrisMd

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