[Вот код ошибки при попытке включить ссылку на ячейку] [1]
Private Sub adduserCommandButton_Click()
Dim finduserrow As Range
Dim rowNo As Integer
Dim findsalesrow As Range
Dim salesNo As Integer
Dim icounter As Long
Dim sales As String
Dim sumformula As String
Dim username As String
Dim lastrow As Long
Dim userMsheet As Worksheet
Dim currentSheetname As Worksheet
Set userMsheet = Sheets("User&Sales Maintenance")
sales = "No. of Sales"
'Value to search for user row
Set findsalesrow = ActiveSheet.Range("C:C").Find(What:=sales)
username = usernameComboBox.Text
If findsalesrow Is Nothing Then
MsgBox "User not found! Please add user!"
Else
salesNo = findsalesrow.Row
sumformula = "=Sum(H" & salesNo - 1 & " : H" & salesNo & ")"
ActiveSheet.Rows(salesNo - 1).Insert Shift:=xlShiftDown,
CopyOrigin:=xlFormatFromRightOrBelow
ActiveSheet.Rows(salesNo - 1).Insert Shift:=xlShiftDown,
CopyOrigin:=xlFormatFromRightOrBelow
ActiveSheet.Cells(salesNo - 1, 2).Value = countryTextBox.Value
ActiveSheet.Cells(salesNo - 1, 3).Value = usernameComboBox.Value
ActiveSheet.Cells(salesNo - 1, 5).Value = ActiveSheet.Name & "IPC Dual
Routers & Leased Lines"
ActiveSheet.Cells(salesNo - 1, 8).Formula = "=$H$5"
ActiveSheet.Cells(salesNo, 4).Value = companyComboBox.Value
ActiveSheet.Cells(salesNo, 5).Value = ActiveSheet.Name & "Client
connection -" & companyComboBox.Value
ActiveSheet.Cells(salesNo, 6).Value = oneTimeTextBox.Value
ActiveSheet.Cells(salesNo, 7).Value = actualMonthlyTextBox.Value
ActiveSheet.Cells(salesNo, 8).Value = actualMonthlyTextBox.Value
ActiveSheet.Cells(salesNo, 9).Value = "Monthly Cost Charge Gross on " &
usernameComboBox.Value
ActiveSheet.Rows(salesNo + 1).Insert Shift:=xlShiftDown,
CopyOrigin:=xlFormatFromRightOrBelow
ActiveSheet.Range(Cells(salesNo + 1, 2), Cells(salesNo + 1, 10)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 8388736
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveSheet.Cells(salesNo + 1, 5).Value = "Subtotal for " &
usernameComboBox.Value
ActiveSheet.Cells(salesNo + 1, 5).Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.Bold = True
End With
ActiveSheet.Cells(salesNo + 1, 8).Value = sumformula
ActiveSheet.Cells(salesNo + 1, 8).Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.Bold = True
End With
MsgBox username & " 's Details Has Been added!"
countryTextBox.Text = ""
companyComboBox.Text = ""
usernameComboBox.Text = ""
oneTimeTextBox.Text = ""
actualMonthlyTextBox.Text = ""
With userMsheet
lastrow = Sheets("User&Sales Maintenance").Range("A" &
Rows.Count).End(xlUp).Row
Sheets("User&Sales Maintenance").Cells(lastrow + 1, "A").Formula =
"=HYPERLINK(" & ActiveSheet.Name & "!" & Cells(salesNo - 1, 3).Address
& "," & usernameComboBox.Value & ")"
End With
End If
End Sub
Также имя активного листа называется Sharing Company, поэтому цель состоит в том, чтобы связать ячейку с Sheet ("Обслуживание пользователей и продаж) к этому рабочему листу под названием Sharing Company с соответствующими ячейками
Может ли кто-нибудь объяснить мне, как решить эту проблему? Я не могу понять, когда и где ставить & и кавычки, когдаиспользуя activesheet.name, а также ячейки (salesno - 1, 3) в скрипте. Заранее спасибо!