Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Revise Code to Allow for Row1

Posted on 2011-03-16
3
Medium Priority
?
349 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 1000 total points
ID: 35150979
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 1000 total points
ID: 35150986
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
ID: 35151200
Thanks Posted right at the same time...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

886 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