Help with row command
Solved/Closed
Related:
- Help with row command
- Cs 1.6 money command - Guide
- Change computer name command line - Guide
- Saints row 2 cheats - Guide
- Net send command - Guide
- Csgo speed command - Guide
2 responses
Copy the sub below into the worksheet you want it to be in.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Make a variable to hold the range the user selected.
Dim RR As Range
'If the selection is not in the first column...
If Target.Column <> 1 Then
'If this row does not have a '1' in the cell...
If Cells(Target.Row, 1) <> "1" Then
'Hold the range the user selected.
Set RR = Target
'Find the '1' that was in the first column.
Range("A1").Select
Selection.End(xlDown).Select
'Clear the '1'
ActiveCell.FormulaR1C1 = ""
'Put the '1' in the correct row.
Cells(RR.Row, 1) = "1"
'Put the selection back where the user had it.
RR.Select
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Make a variable to hold the range the user selected.
Dim RR As Range
'If the selection is not in the first column...
If Target.Column <> 1 Then
'If this row does not have a '1' in the cell...
If Cells(Target.Row, 1) <> "1" Then
'Hold the range the user selected.
Set RR = Target
'Find the '1' that was in the first column.
Range("A1").Select
Selection.End(xlDown).Select
'Clear the '1'
ActiveCell.FormulaR1C1 = ""
'Put the '1' in the correct row.
Cells(RR.Row, 1) = "1"
'Put the selection back where the user had it.
RR.Select
End If
End If
End Sub
You're Welcome, when testing it I just saw that it doesn't work in the very first row it leaves the 1 in row 1. In order to fix this you need a slight mod... (below...)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Make a variable to hold the range the user selected.
Dim RR As Range
'If the selection is not in the first column...
If Target.Column <> 1 Then
'If this row does not have a '1' in the cell...
If Cells(Target.Row, 1) <> "1" Then
'Hold the range the user selected.
Set RR = Target
'Find the '1' that was in the first column.
Range("A1").Select
ActiveCell.FormulaR1C1 = "" '(This extra line will clear the '1' if it's in the first row.)
Selection.End(xlDown).Select
'Clear the '1'
ActiveCell.FormulaR1C1 = ""
'Put the '1' in the correct row.
Cells(RR.Row, 1) = "1"
'Put the selection back where the user had it.
RR.Select
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Make a variable to hold the range the user selected.
Dim RR As Range
'If the selection is not in the first column...
If Target.Column <> 1 Then
'If this row does not have a '1' in the cell...
If Cells(Target.Row, 1) <> "1" Then
'Hold the range the user selected.
Set RR = Target
'Find the '1' that was in the first column.
Range("A1").Select
ActiveCell.FormulaR1C1 = "" '(This extra line will clear the '1' if it's in the first row.)
Selection.End(xlDown).Select
'Clear the '1'
ActiveCell.FormulaR1C1 = ""
'Put the '1' in the correct row.
Cells(RR.Row, 1) = "1"
'Put the selection back where the user had it.
RR.Select
End If
End If
End Sub
Sep 26, 2008 at 02:33 PM
Thank you for your immidiate reply! ;) You just made my day.
Best regards,
Mark