ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Method 'Range' of object '_Global' failed (https://www.excelbanter.com/excel-programming/275199-method-range-object-_global-failed.html)

Mohanasundaram[_2_]

Method 'Range' of object '_Global' failed
 
Hi All,

I have the following code in my Excel Macro.
While running this macro I am getting the following error
"Method 'Range' of object '_Global' failed"
What is wrong with this code

Dim i As Long
Dim s As String
i = 1

While (1)
s = "G" + CStr(i)
If Range(s).Value = "Completed" Then
Range(s).EntireRow.Hidden = True
End If

i = i + 1
Wend

Regards,
Moahn.

John[_48_]

Method 'Range' of object '_Global' failed
 
Mohanasundaram,

No termination possible with "While (1)"

try -

Dim i As Long
Dim s As String
i = 1

While (i <= Cells.Rows.Count)
s = "G" + CStr(i)
If Range(s).Value = "Completed" Then
Range(s).EntireRow.Hidden = True
End If

i = i + 1
Wend

regards,

John

"Mohanasundaram" wrote in message
om...
Hi All,

I have the following code in my Excel Macro.
While running this macro I am getting the following error
"Method 'Range' of object '_Global' failed"
What is wrong with this code

Dim i As Long
Dim s As String
i = 1

While (1)
s = "G" + CStr(i)
If Range(s).Value = "Completed" Then
Range(s).EntireRow.Hidden = True
End If

i = i + 1
Wend

Regards,
Moahn.





All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com