Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Revise Code to Allow for Row1

Posted on 2011-03-16
3
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

721 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