Solved

Revise Code to Allow for Row1

Posted on 2011-03-16
3
334 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 250 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 250 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

739 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