sandeep9dec
New Member
- Joined
- Nov 29, 2014
- Messages
- 13
Hi,
I am very new to the VBA programming in below program i ma receiving the Run time error 9. at red color highlighted place.
can some one help to resolve this issue.
I am very new to the VBA programming in below program i ma receiving the Run time error 9. at red color highlighted place.
can some one help to resolve this issue.
Rich (BB code):
Dim iRow, iCol As Integer
Dim strColName As String
Dim strColFGCode As String
Dim strColPName As String
Dim strColHLink As String
Dim bValidate As Boolean
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
GetValues (Target.Row)
If Target.Column = 4 And strColHLink = Empty And Target.Row <> 1 Then
If strColFGCode = Empty Then
MsgBox "Empty Row", vbInformation, "FC Code"
Else
If IsDuplicate(Target.Row) = True Then
MsgBox "Duplicate FC Code exists ! ", vbInformation, "FC Code"
Else
CreateCopy strColFGCode
End If
End If
Else
If Target.Column = 4 Then
Worksheets(strColFGCode).Activate
End If
End If
End Sub
Sub GetValues(iRow As Integer)
rw = Worksheets("INDEX").Rows(iRow)
strColName = rw(1, 1)
strColFGCode = rw(1, 2)
strColPName = rw(1, 3)
strColHLink = rw(1, 4)
End Sub
Sub CreateCopy(FCode As String)
Sheets("Main").Select
Sheets("Main").Copy After:=Sheets(Sheets.Count)
Sheets("Main (2)").Select
Sheets("Main (2)").Name = FCode
ActiveWorkbook.Save
Worksheets("INDEX").Activate
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
FCode + "!A1", TextToDisplay:="Select " + FCode
End Sub
Function IsDuplicate(iRow As Integer) As Boolean
Set FindRow = Worksheets("INDEX").Range("B:B").Find(What:=strColFGCode, LookIn:=xlValues)
If FindRow.Row = iRow Then
IsDuplicate = False
Else
IsDuplicate = True
End If
End Function
Private Sub Worksheet_Activate()
Dim Cell As Range
With ActiveSheet
.Protect Password:="Hetvi123"
'Protect with blank password, you can change it
End With
End Sub
Last edited by a moderator: