In I4 of either sheet--or the next row in either sheet?
Private Sub BtnSaveInfo_Click()
Dim Sht As Worksheet
Dim myFileName As Variant
Dim NextRow As Long
dim myFormula as string
myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
myformula = ""
Else
myformula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """)"
Me.DocFilePath.Value = myFileName
End If
If Laptop1.Value = True Then
Set Sht = ThisWorkbook.Worksheets("Toshiba (00226)")
else
Set Sht = ThisWorkbook.Worksheets("Dell (B000234)")
end if
with Sht
Sht.Range("A4").Value = TextBox2.Text
Sht.Range("B4").Value = RecDate.Text
Sht.Range("C4").Value = RSVers.Text
Sht.Range("D4").Value = CachVers.Text
Sht.Range("E4").Value = ApacVers.Text
Sht.Range("F4").Value = TomcVers.Text
Sht.Range("G4").Value = JavVers.Text
Sht.Range("H4").Value = TextBox1.Text
Sht.Range("J4").Value = mailworkdone1.Text
'not sure which one should be used
NextRow = .Cells(.Rows.Count, "I").End(xlUp).Row + 1
sht.Cells(NextRow, "I").Formula = myFormula
'or
'sht.range("I4").formula = myformula
end with
End Sub
Uncompiled, untested.
If you only have two option buttons, you can probably check one and decide what
to. And since the cells getting the value are the same addresses, you can just
use that "with sht" after deciding which sheet to use.
Hi Dave
Thanks for giving the code in your last response. It work as I wanted.
There is something else Id like to ask you in connection with this....
The form in which the browse buttons sits has other information which needs
to be entered. There are 2 radion buttons called radiobutton1 and
radiobutton2, depending on which button is selected the information is copied
into the respective sheet (laptop1 or laptop2). Below is the code for this
condition:
Private Sub BtnSaveInfo_Click()
Dim Sht As Worksheet
If Laptop1.Value = True Then
Set Sht = ThisWorkbook.Worksheets("Toshiba (00226)")
Sht.Range("A4").Value = TextBox2.Text
Sht.Range("B4").Value = RecDate.Text
Sht.Range("C4").Value = RSVers.Text
Sht.Range("D4").Value = CachVers.Text
Sht.Range("E4").Value = ApacVers.Text
Sht.Range("F4").Value = TomcVers.Text
Sht.Range("G4").Value = JavVers.Text
Sht.Range("H4").Value = TextBox1.Text
Sht.Range("J4").Value = mailworkdone1.Text
End If
If Laptop2.Value = True Then
Set Sht = ThisWorkbook.Worksheets("Dell (B000234)")
Sht.Range("A4").Value = TextBox2.Text
Sht.Range("B4").Value = RecDate.Text
Sht.Range("C4").Value = RSVers.Text
Sht.Range("D4").Value = CachVers.Text
Sht.Range("E4").Value = ApacVers.Text
Sht.Range("F4").Value = TomcVers.Text
Sht.Range("G4").Value = JavVers.Text
Sht.Range("H4").Value = TextBox1.Text
Sht.Range("J4").Value = mailworkdone1.Text
End If
End Sub
Now, what Id like to do is integrate the hyperlink code with the above, so
that depending on which radio button is selected the hyperlink file path gets
copied into the respective sheet (laptop1 or laptop2) in row I the same time
as when all the above info gets copied (as it is a part of the info in that
row). tHIS IS THE HYPERLINK CODE THAT i HAVE:
Private Sub CommandButton4_Click()
Dim myFileName As Variant
Dim NextRow As Long
With ActiveSheet
NextRow = .Cells(.Rows.Count, "I").End(xlUp).Row + 1
End With
myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")
If myFileName = False Then
Beep 'do nothing???
Else
ActiveSheet.Cells(NextRow, "I").Formula _
= "=hyperlink(""file:////""&" _
& """" & myFileName & """)"
Me.DocFilePath.Value = myFileName
End If
End Sub
iS THERE anyway to link the two pieces of code?
Thanks Dave