isaiasenzo
New Member
- Joined
- Feb 26, 2019
- Messages
- 4
Hello,
I am a bit of a newbie to VBA and macros.
I am currently using the following code to download data in real time. The data is downloaded from an Excel sheet that is updated in real time.
At first it gives an error, I give it ok and the data is saved, but when I want to add this data, an error appears: Error
Runtime error '-2147417848':
Method 'Rows' of object '_Global' Error
and the macro stops running.
Can someone help me with this?
The code is the following:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dim Habla As String
Dim Habla1 As String
Dim Temp1 As Double
Dim TempC1 As Double
Dim TempC2 As Double
Dim Temp2 As Double
Dim TempP1 As Double
Dim TempP2 As Double
Dim hablatemp1 As Double
Dim hablatemp2 As Double
Private Sub Worksheet_Calculate()
Dim ultimafilaauxiliarZN1 As Long
If (Range("D23").Value <> Temp1) Then
If (ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row) > (ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row) Then
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row - 1
Else
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row
End If
If ((Range("D23").Value - Temp1) > Range("N1").Value) Then
If (Temp1 > 0) Then
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 14) = Range("D23").Value - Temp1 'HERE GIVES THE ERROR THE DEBUG
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 16) = Range("D33").Value - TempC1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 17) = Range("D34").Value - TempC2
End If
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 12) = Range("D23").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 13) = Range("D44").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 15) = Time
hablatemp1 = Range("D23").Value - Temp1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 18) = Range("D48").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 19) = Range("D49").Value
If ((hablatemp1) > "1") Then
Habla1 = Range("D2")
Application.Speech.Speak Habla1
End If
End If
Temp1 = Range("D23").Value
TempC1 = Range("D33").Value
TempC2 = Range("D34").Value
End If
If (Range("D24").Value <> Temp2) Then
If (ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row) > (ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row) Then
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row
Else
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row
End If
If ((Range("D24").Value - Temp2) > Range("AA1").Value) Then
If (Temp2 > 0) Then
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 27) = Range("D24").Value - Temp2
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 29) = Range("E33").Value - TempP1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 30) = Range("E34").Value - TempP2
End If
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 25) = Range("D24").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 26) = Range("D45").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 28) = Time
hablatemp2 = Range("D24").Value - Temp2
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 31) = Range("D48").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 32) = Range("D49").Value
If ((hablatemp2) > "1000") Then
Habla1 = Range("D2")
Application.Speech.Speak Habla1
End If
End If
Temp2 = Range("D24").Value
TempP1 = Range("E33").Value
TempP2 = Range("E34").Value
End If
End Sub
Regards
ISAIAS
I am a bit of a newbie to VBA and macros.
I am currently using the following code to download data in real time. The data is downloaded from an Excel sheet that is updated in real time.
At first it gives an error, I give it ok and the data is saved, but when I want to add this data, an error appears: Error
Runtime error '-2147417848':
Method 'Rows' of object '_Global' Error
and the macro stops running.
Can someone help me with this?
The code is the following:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dim Habla As String
Dim Habla1 As String
Dim Temp1 As Double
Dim TempC1 As Double
Dim TempC2 As Double
Dim Temp2 As Double
Dim TempP1 As Double
Dim TempP2 As Double
Dim hablatemp1 As Double
Dim hablatemp2 As Double
Private Sub Worksheet_Calculate()
Dim ultimafilaauxiliarZN1 As Long
If (Range("D23").Value <> Temp1) Then
If (ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row) > (ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row) Then
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row - 1
Else
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row
End If
If ((Range("D23").Value - Temp1) > Range("N1").Value) Then
If (Temp1 > 0) Then
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 14) = Range("D23").Value - Temp1 'HERE GIVES THE ERROR THE DEBUG
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 16) = Range("D33").Value - TempC1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 17) = Range("D34").Value - TempC2
End If
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 12) = Range("D23").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 13) = Range("D44").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 15) = Time
hablatemp1 = Range("D23").Value - Temp1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 18) = Range("D48").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 19) = Range("D49").Value
If ((hablatemp1) > "1") Then
Habla1 = Range("D2")
Application.Speech.Speak Habla1
End If
End If
Temp1 = Range("D23").Value
TempC1 = Range("D33").Value
TempC2 = Range("D34").Value
End If
If (Range("D24").Value <> Temp2) Then
If (ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row) > (ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row) Then
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("U" & Rows.Count).End(xlUp).Row
Else
ultimafilaauxiliarZN1 = ThisWorkbook.Sheets("Hoja1").Range("L" & Rows.Count).End(xlUp).Row
End If
If ((Range("D24").Value - Temp2) > Range("AA1").Value) Then
If (Temp2 > 0) Then
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 27) = Range("D24").Value - Temp2
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 29) = Range("E33").Value - TempP1
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 30) = Range("E34").Value - TempP2
End If
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 25) = Range("D24").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 26) = Range("D45").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 28) = Time
hablatemp2 = Range("D24").Value - Temp2
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 31) = Range("D48").Value
ThisWorkbook.Sheets("Hoja1").Cells(ultimafilaauxiliarZN1 + 1, 32) = Range("D49").Value
If ((hablatemp2) > "1000") Then
Habla1 = Range("D2")
Application.Speech.Speak Habla1
End If
End If
Temp2 = Range("D24").Value
TempP1 = Range("E33").Value
TempP2 = Range("E34").Value
End If
End Sub
Regards
ISAIAS