PritishS
Board Regular
- Joined
- Dec 29, 2015
- Messages
- 119
- Office Version
- 2007
- Platform
- Windows
Dear Sir,
I want to restrict user from selecting entire row in an Application.InputBox. I don't want to password protect my worksheet.
I just want user to select a cell in A column only. That I have done. If user select any cell in any column except A column, it stops user from doing that.
But I can not restrict user to select entire row. Any help will be much appreciated!!
My code is as below
Thanks in Advance
PritishS
I want to restrict user from selecting entire row in an Application.InputBox. I don't want to password protect my worksheet.
I just want user to select a cell in A column only. That I have done. If user select any cell in any column except A column, it stops user from doing that.
But I can not restrict user to select entire row. Any help will be much appreciated!!
My code is as below
VBA Code:
Sub Copy_to_Sheet()
Dim FromRange As Range
Dim ToRange As Range
Dim rownum As Long
Dim Rng As Range
Dim answer As Integer
On Error GoTo Whoa
rownum = InputBox("Enter Row Number to Copy.")
Set Rng = Range(Cells(rownum, 1), Cells(rownum, 4))
Set FromRange = Rng
Sheets("Sheet2").Activate
Set ToRange = Application.InputBox("Click on a cell to Paste : ", Type:=8)
'Selettion of Range for component in A column only
If ToRange(1).Column <> 1 Then
MsgBox "You selected range """ & ToRange.Address(0, 0) & """ which does not span Columns A!", vbCritical
Else
FromRange.SpecialCells(xlCellTypeVisible).Copy ToRange
answer = MsgBox("Data changed on selected area.", vbOKOnly + vbExclamation, "Information")
End If
Whoa:
Select Case Err.Number
Case 13
answer = MsgBox("This box can not be blank or You have clicked on 'Cancel' button. Operation Cancelled!!", vbOKOnly + vbExclamation, "Information")
'Added for refreshing the screen
Application.ScreenUpdating = True
Case 1004
answer = MsgBox("Entire row should not be selected. Try again by selection cells in A column only!!", vbOKOnly + vbExclamation, "Information")
'Added for refreshing the screen
Application.ScreenUpdating = True
End Select
End Sub
Thanks in Advance
PritishS