Solved

Revise Code to Allow for Row1

Posted on 2011-03-16
3
323 Views
Last Modified: 2012-06-21
Excel 2003
vba

I have a userform that has a command button
with this code

Private Sub cmdCancel_Click()
' What happens if no selection... and I'm in row 2 with row 1 blocked

Sheets("sheet1").Activate
ActiveCell.Offset(-1, 1).Range("A1").Value = ""
ActiveCell.Offset(-1, 2).Range("A1").Value = ""
ActiveCell.Offset(-1, 3).Range("A1").Value = ""
ActiveCell.Offset(-1, 8).Range("A1").Value = "Reviewed But No Selection Made"
Range(ActiveCell.Offset(-1, 11), ActiveCell.Offset(-1, 43)).Value = ""
Unload Me
End Sub

I have row 1  protected..

I need to update the code so it will IGNORE ROW 1 if a person is in row 2


Thanks
fordraiders
0
Comment
Question by:fordraiders
3 Comments
 
LVL 9

Accepted Solution

by:
McOz earned 250 total points
Comment Utility
Wrap the code in an "IF" that only runs if the row is greater than 2:
Private Sub cmdCancel_Click()

If ActiveCell.Row > 2 Then
 Sheets("sheet1").Activate
 ActiveCell.Offset(-1, 1).Range("A1").Value = ""
 ActiveCell.Offset(-1, 2).Range("A1").Value = ""
 ActiveCell.Offset(-1, 3).Range("A1").Value = ""
 ActiveCell.Offset(-1, 8).Range("A1").Value = "Reviewed But No Selection Made"
 Range(ActiveCell.Offset(-1, 11), ActiveCell.Offset(-1, 43)).Value = ""
End If
Unload Me
End Sub

Open in new window

0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 250 total points
Comment Utility
Try like this...

jppinto
Private Sub cmdCancel_Click()
' What happens if no selection... and I'm in row 2 with row 1 blocked

    If ActiveCell.Row <> 2 Then
        Sheets("sheet1").Activate
        ActiveCell.Offset(-1, 1).Range("A1").Value = ""
        ActiveCell.Offset(-1, 2).Range("A1").Value = ""
        ActiveCell.Offset(-1, 3).Range("A1").Value = ""
        ActiveCell.Offset(-1, 8).Range("A1").Value = "Reviewed But No Selection Made"
        Range(ActiveCell.Offset(-1, 11), ActiveCell.Offset(-1, 43)).Value = ""
        Unload Me
    End If

End Sub

Open in new window

0
 
LVL 3

Author Closing Comment

by:fordraiders
Comment Utility
Thanks Posted right at the same time...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now