Hi all,
I'd need some help. I have the following VBA, and everything is working properly except the simplest thing: the automtical hide-unhide part I saw from Mr.Excel:
Please note, that this is my very first VBA ever, and I'd need it for work. That is my main project I would like to fulfill.
Thank you very much for your help!!!
I wish you all a lovely day!
Timi from Hungary.
I'd need some help. I have the following VBA, and everything is working properly except the simplest thing: the automtical hide-unhide part I saw from Mr.Excel:
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
LinkTo = Target.SubAddress
WhereBang = InStr(1, LinkTo, "!")
If WhereBank > 0 Then
MySheet = Left(LinkTo, WhereBang - 1)
Worksheets(MySheet).Visible = True
Worksheets(MySheet).Select
Myaddr = Mid(LinkTo, WhereBang + 1)
Worksheets(MySheet).Range(Myaddr).Select
End If
End Sub
I am wondering if the other VBAs could confuse it? Actually If I hide the sheets, and try to clik on the Link, nothing happenes. :(
See the full VBA here:
Private Sub SEARCH_Click()
Dim lastrow As Long, myentry As Long
lastrow = Sheets("item_price").Cells(Rows.count, 1).End(xlUp).Row
'MsgBox lastrow
'Sheets("item_price").Activate
For X = 2 To lastrow
' myentry = Sheet2.Range("B3").Value
'MsgBox myentry
If Sheets("item_price").Cells(X, 1).Value = Sheet2.Range("B3").Value Then
Sheet2.Range("A11").Value = Sheets("item_price").Cells(X, 1).Value
Sheet2.Range("B11").Value = Sheets("item_price").Cells(X, 2).Value
Sheet2.Range("C11").Value = Sheets("item_price").Cells(X, 3).Value
Sheet2.Range("D11").Value = Sheets("item_price").Cells(X, 4).Value
Sheet2.Range("E11").Value = Sheets("item_price").Cells(X, 5).Value
End If
Next X
End Sub
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
LinkTo = Target.SubAddress
WhereBang = InStr(1, LinkTo, "!")
If WhereBank > 0 Then
MySheet = Left(LinkTo, WhereBang - 1)
Worksheets(MySheet).Visible = True
Worksheets(MySheet).Select
Myaddr = Mid(LinkTo, WhereBang + 1)
Worksheets(MySheet).Range(Myaddr).Select
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2018/9/21
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
If Target.Validation.Type = 3 Then
Target.Validation.InCellDropdown = False
Cancel = True
xStr = Target.Validation.Formula1
xStr = Right(xStr, Len(xStr) - 1)
If xStr = "" Then Exit Sub
With xCombox
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = xStr
If .ListFillRange = "" Then
xArr = Split(xStr, ",")
Me.TempCombo.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.TempCombo.DropDown
End If
End Sub
Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case KeyCode
Case 9
Application.ActiveCell.Offset(0, 1).Activate
Case 13
Application.ActiveCell.Offset(1, 0).Activate
End Select
End Sub
Please note, that this is my very first VBA ever, and I'd need it for work. That is my main project I would like to fulfill.
Thank you very much for your help!!!
I wish you all a lovely day!
Timi from Hungary.
Last edited by a moderator: