Solved

Revise Code to Allow for Row1

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell add exchange property to a report 12 52
VBA Help 18 46
Excel Formula to check both condition's and return values 2 34
Copying from excel I am getting extra text 11 44
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

831 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