I am trying to make a code that makes the program write data in a specific excel spreadsheet according to the value of the variable "MachineName" declared as public
What happens is that the program does not allow me to do it because an error is detected on line 96
The error:
The code is that:
Can anyone help me?
What happens is that the program does not allow me to do it because an error is detected on line 96
The error:
The code is that:
VBA Code:
Sub KillEmpty()
Dim sh As Worksheet
Dim k As Long
Range("C4").Select
If MachineName = "A4" Then
Set sh = ThisWorkbook.Sheets("A4")
ElseIf MachineName = "A8.1" Then
Set sh = ThisWorkbook.Sheets("A8_1")
ElseIf MachineName = "A8.2" Then
Set sh = ThisWorkbook.Sheets("A8_2")
ElseIf MachineName = "A8.3" Then
Set sh = ThisWorkbook.Sheets("A8_3")
ElseIf MachineName = "A12.1" Then
Set sh = ThisWorkbook.Sheets("A12_1")
ElseIf MachineName = "A12.2" Then
Set sh = ThisWorkbook.Sheets("A12_2")
ElseIf MachineName = "A12.3" Then
Set sh = ThisWorkbook.Sheets("A12_3")
ElseIf MachineName = "A20.1" Then
Set sh = ThisWorkbook.Sheets("A20_1")
ElseIf MachineName = "A20.2" Then
Set sh = ThisWorkbook.Sheets("A20_2")
End If
k = sh.Range("C4", sh.Range("C4").End(xlDown)).Rows.Count
If ActiveCell.Value = "" Then
Call FillCells
ElseIf ActiveCell.Value <> "" Then
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop
Call FillCells
End If
End Sub
Can anyone help me?