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/343953-method-range-object-_global-failed.html)

Schades

method 'range' of object '_global' failed
 
I get the error: Method 'Range' of object '_glogal' failed

I run the following call files code and it is giving me an error around
CStr(Range("PropCode1").Value).

Below is the table it references to pull the files. All files are
spelled correctly.

Counter1 1
TotCount1 106
PropCode1 AL


Sub CallFiles()

ChDir "C:\Documents and Settings\user"

Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


' loop thru all the properties on the Props sheet
For i = 1 To CStr(Range("TotCount1").Value)
Range("Counter1") = i
Calculate
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"

FINAL_CORRECTIONS

Next i


End Sub

2nd MACRO [first few lines]:

Sub FINAL_CORRECTIONS()


Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


ChDir "C:\Documents and Settings\user"
Workbooks.Open strFileName

FilePass = Sheets("DATASHEET").Range("E1")
Sheets("Corporate").Select
Range("H7").Select
ActiveSheet.Unprotect Password:=CStr(Range("FilePass"))
ActiveWorkbook.Unprotect Password:=CStr(Range("FilePass"))
Sheets("DATASHEET").Visible = True
ActiveWindow.LargeScroll ToRight:=-1
Sheets("DATASHEET").Select
Range("J7").Select
ActiveCell.FormulaR1C1 = "0%"
Range("J8").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Calc Sheet").Visible = True
....


Jim Rech

method 'range' of object '_global' failed
 
Range("PropCode1").Value

The above giving a range method failed error is a strong indication that
that range does not exist on the active worksheet. Does that name appear in
the the Define Name dialog when you press Ctrl-F3?

--
Jim
"Schades" wrote in message
oups.com...
I get the error: Method 'Range' of object '_glogal' failed

I run the following call files code and it is giving me an error around
CStr(Range("PropCode1").Value).

Below is the table it references to pull the files. All files are
spelled correctly.

Counter1 1
TotCount1 106
PropCode1 AL


Sub CallFiles()

ChDir "C:\Documents and Settings\user"

Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


' loop thru all the properties on the Props sheet
For i = 1 To CStr(Range("TotCount1").Value)
Range("Counter1") = i
Calculate
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"

FINAL_CORRECTIONS

Next i


End Sub

2nd MACRO [first few lines]:

Sub FINAL_CORRECTIONS()


Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


ChDir "C:\Documents and Settings\user"
Workbooks.Open strFileName

FilePass = Sheets("DATASHEET").Range("E1")
Sheets("Corporate").Select
Range("H7").Select
ActiveSheet.Unprotect Password:=CStr(Range("FilePass"))
ActiveWorkbook.Unprotect Password:=CStr(Range("FilePass"))
Sheets("DATASHEET").Visible = True
ActiveWindow.LargeScroll ToRight:=-1
Sheets("DATASHEET").Select
Range("J7").Select
ActiveCell.FormulaR1C1 = "0%"
Range("J8").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Calc Sheet").Visible = True
...




Alok

method 'range' of object '_global' failed
 
Hi

I have found that quite a few problems can arise when ranges are not
qualified. Try qualifying them with the names of the worksheets.

Alok

"Schades" wrote:

I get the error: Method 'Range' of object '_glogal' failed

I run the following call files code and it is giving me an error around
CStr(Range("PropCode1").Value).

Below is the table it references to pull the files. All files are
spelled correctly.

Counter1 1
TotCount1 106
PropCode1 AL


Sub CallFiles()

ChDir "C:\Documents and Settings\user"

Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


' loop thru all the properties on the Props sheet
For i = 1 To CStr(Range("TotCount1").Value)
Range("Counter1") = i
Calculate
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"

FINAL_CORRECTIONS

Next i


End Sub

2nd MACRO [first few lines]:

Sub FINAL_CORRECTIONS()


Dim i As Integer
Dim strFileName As String
strFileName = CStr(Range("PropCode1").Value) & "-Budget06.xls"
Application.DisplayAlerts = False


ChDir "C:\Documents and Settings\user"
Workbooks.Open strFileName

FilePass = Sheets("DATASHEET").Range("E1")
Sheets("Corporate").Select
Range("H7").Select
ActiveSheet.Unprotect Password:=CStr(Range("FilePass"))
ActiveWorkbook.Unprotect Password:=CStr(Range("FilePass"))
Sheets("DATASHEET").Visible = True
ActiveWindow.LargeScroll ToRight:=-1
Sheets("DATASHEET").Select
Range("J7").Select
ActiveCell.FormulaR1C1 = "0%"
Range("J8").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Calc Sheet").Visible = True
....




All times are GMT +1. The time now is 10:32 AM.

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