Hi all!
I am still new to vba and doing a data input code where the user will be prompt to enter 4 different values on the first row. Once it reach the 4th column, the user will be prompt whether he/she wants to continue. If the user continues, the new values will be input into the 2nd row and also until the 4th column. At each row, the input values for second row will be hyperlink whereas the user will be prompt to select the file directory and it will then hyperlink the second column values to the directory selected.
Below is the code.
The current results for this code is as shown below after 2 different inputs.
<tbody>
</tbody>
Errors:
-B1 is hyperlink however when a new value is insert, B1 will show that it is hyperlink however it is not.
-B2 is hyperlink however it input another unhyperlink of the same values at row 3.
I need help debugging my code so that B1 will be hyperlink to its file directory and so is B2 without entering another B2 on row 3 every time a new value is input.
Thank you!
PS. I am using excel 2003.
I am still new to vba and doing a data input code where the user will be prompt to enter 4 different values on the first row. Once it reach the 4th column, the user will be prompt whether he/she wants to continue. If the user continues, the new values will be input into the 2nd row and also until the 4th column. At each row, the input values for second row will be hyperlink whereas the user will be prompt to select the file directory and it will then hyperlink the second column values to the directory selected.
Below is the code.
Code:
Private Sub CommandButton1_Click()
Dim Name, desp, iname, prtno, fldr As String
Dim i As Integer
Dim fnsh As Long
1:
Name = InputBox("Company name?")
If Name <> "" Then
If IsEmpty(Cells(1, 1)) Then
Cells(1, 1).Value = Name
Else
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Name
End If
End If
prtno = Application.InputBox("Please Enter File Extension", "Info Request")
If prtno = False And Not TypeName(y) = "String" Then Exit Sub
Application.ScreenUpdating = False
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
fldr = .SelectedItems(1)
End With
With Application.FileSearch
.NewSearch
.LookIn = fldr
.SearchSubFolders = True
.Filename = prtno
If prtno <> "" Then
If IsEmpty(Cells(1, 2)) Then
Cells(1, 2).Value = prtno
Else
ActiveSheet.Hyperlinks.Add anchor:=Cells(Rows.Count, 2).End(xlUp).Offset(1, 0), Address:=fldr, TextToDisplay:=prtno
Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Value = prtno
End If
End If
End With
desp = InputBox("Part Description?")
If desp <> "" Then
If IsEmpty(Cells(1, 3)) Then
Cells(1, 3).Value = desp
Else
Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Value = desp
End If
End If
iname = InputBox("Name?")
If iname <> "" Then
If IsEmpty(Cells(1, 4)) Then
Cells(1, 4).Value = iname
Else
Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).Value = iname
End If
End If
i = MsgBox("Continue?", vbYesNo)
If i = vbYes Then GoTo 1 Else GoTo 2
2:
MsgBox ("End")
End Sub
The current results for this code is as shown below after 2 different inputs.
A1 | B1 | C1 | D1 |
A2 | B2 | C2 | D2 |
B2 | |||
<tbody>
</tbody>
Errors:
-B1 is hyperlink however when a new value is insert, B1 will show that it is hyperlink however it is not.
-B2 is hyperlink however it input another unhyperlink of the same values at row 3.
I need help debugging my code so that B1 will be hyperlink to its file directory and so is B2 without entering another B2 on row 3 every time a new value is input.
Thank you!
PS. I am using excel 2003.
Last edited: