Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Subscript out of ranges - Friend8899


I am new in Excel VBA program. I have recently try to write a program
in order to write the data to DBF file. I encountered Subscript out of
range. The program does not seem to detect the DBF file even I open the
file. Can someone please help. Thanks in advance for your help.


Sub Open_file()
Dim DBase_File As String
Dim Home As String
Home = ActiveWorkbook.Name
DBase_File = Sheets("Options").Range("C7")
Workbooks.Open Filename:=DBase_File
Workbooks(Home).Activate
Call Update_GL
End Sub


Sub Update_GL()
Dim TB_Rec As Long
Dim DBase_File As String
Dim Dbase_Sht As String

TB_Rec = Sheets("Options").Range("C21")
DBase_File = Sheets("Options").Range("C7")
Dbase_Sht = Sheets("Options").Range("C8")
Sheets("Payment").Activate.Range("A4:A" & TB_Rec&, "C4:C" &
TB_Rec). _
Copy
Destination:=Workbooks(DBase_File).Sheets(Dbase_Sh t).Range("A1")

End Sub


The variable defined in the Option file as follows :


LIST OF WORKBOOK TO OPEN
File name Folder
DBase_File C:\Mydocument\gltest.dbf
Dbase_Sht gltest


No. of Record 5 (TB_Rec)


--
friend8899
------------------------------------------------------------------------
friend8899's Profile: http://www.excelforum.com/member.php...o&userid=24233
View this thread: http://www.excelforum.com/showthread...hreadid=378465

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Subscript out of ranges - Friend8899

You don't say which line causes the error, or even in which sub it
occurs...

The most frequent cause of this error (at least here in the newsgroup)
seems to be referencing a sheet which does not exist in the workbook.
You definitely have a sheet called "Options" ?

Tim.


"friend8899"
wrote in message
...

I am new in Excel VBA program. I have recently try to write a
program
in order to write the data to DBF file. I encountered Subscript out
of
range. The program does not seem to detect the DBF file even I open
the
file. Can someone please help. Thanks in advance for your help.


Sub Open_file()
Dim DBase_File As String
Dim Home As String
Home = ActiveWorkbook.Name
DBase_File = Sheets("Options").Range("C7")
Workbooks.Open Filename:=DBase_File
Workbooks(Home).Activate
Call Update_GL
End Sub


Sub Update_GL()
Dim TB_Rec As Long
Dim DBase_File As String
Dim Dbase_Sht As String

TB_Rec = Sheets("Options").Range("C21")
DBase_File = Sheets("Options").Range("C7")
Dbase_Sht = Sheets("Options").Range("C8")
Sheets("Payment").Activate.Range("A4:A" & TB_Rec&, "C4:C" &
TB_Rec). _
Copy
Destination:=Workbooks(DBase_File).Sheets(Dbase_Sh t).Range("A1")

End Sub


The variable defined in the Option file as follows :


LIST OF WORKBOOK TO OPEN
File name Folder
DBase_File C:\Mydocument\gltest.dbf
Dbase_Sht gltest


No. of Record 5 (TB_Rec)


--
friend8899
------------------------------------------------------------------------
friend8899's Profile:
http://www.excelforum.com/member.php...o&userid=24233
View this thread:
http://www.excelforum.com/showthread...hreadid=378465



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Subscript out of ranges - Friend8899

It has to be that Options doesn't exist, or the filename in C7 doesn't.

--
HTH

Bob Phillips

"friend8899" wrote
in message ...

I am new in Excel VBA program. I have recently try to write a program
in order to write the data to DBF file. I encountered Subscript out of
range. The program does not seem to detect the DBF file even I open the
file. Can someone please help. Thanks in advance for your help.


Sub Open_file()
Dim DBase_File As String
Dim Home As String
Home = ActiveWorkbook.Name
DBase_File = Sheets("Options").Range("C7")
Workbooks.Open Filename:=DBase_File
Workbooks(Home).Activate
Call Update_GL
End Sub


Sub Update_GL()
Dim TB_Rec As Long
Dim DBase_File As String
Dim Dbase_Sht As String

TB_Rec = Sheets("Options").Range("C21")
DBase_File = Sheets("Options").Range("C7")
Dbase_Sht = Sheets("Options").Range("C8")
Sheets("Payment").Activate.Range("A4:A" & TB_Rec&, "C4:C" &
TB_Rec). _
Copy
Destination:=Workbooks(DBase_File).Sheets(Dbase_Sh t).Range("A1")

End Sub


The variable defined in the Option file as follows :


LIST OF WORKBOOK TO OPEN
File name Folder
DBase_File C:\Mydocument\gltest.dbf
Dbase_Sht gltest


No. of Record 5 (TB_Rec)


--
friend8899
------------------------------------------------------------------------
friend8899's Profile:

http://www.excelforum.com/member.php...o&userid=24233
View this thread: http://www.excelforum.com/showthread...hreadid=378465



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Subscript out of ranges - Friend8899


Dear Tim and Bob,

Thanks for your prompt replies. I do have the Option worksheet stated
the Dbase file and Dbase Sheets.

The error occured on "

Sheets("Payment").Activate.Range("A4:A" & TB_Rec&, "C4:C" & TB_Rec). _
Copy Destination:=Workbooks(DBase_File).Sheets(Dbase_Sh t).Range("A1")

That is when I want to write the data to the Database file.

May I know can the VBA program write the data to the Database file
(with Extension .dbf) ? The error seems that it does not find the
database even I have already opened it.

Please advise.



Thanks & Regards

Friend8899


--
friend8899
------------------------------------------------------------------------
friend8899's Profile: http://www.excelforum.com/member.php...o&userid=24233
View this thread: http://www.excelforum.com/showthread...hreadid=378465

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Subscript out of ranges - Friend8899

Is this a type

Sheets(Dbase_Sh t)

should it b e

Sheets(Dbase_Sht).

--
HTH

Bob Phillips

"friend8899" wrote
in message ...

Dear Tim and Bob,

Thanks for your prompt replies. I do have the Option worksheet stated
the Dbase file and Dbase Sheets.

The error occured on "

Sheets("Payment").Activate.Range("A4:A" & TB_Rec&, "C4:C" & TB_Rec). _
Copy Destination:=Workbooks(DBase_File).Sheets(Dbase_Sh t).Range("A1")

That is when I want to write the data to the Database file.

May I know can the VBA program write the data to the Database file
(with Extension .dbf) ? The error seems that it does not find the
database even I have already opened it.

Please advise.



Thanks & Regards

Friend8899


--
friend8899
------------------------------------------------------------------------
friend8899's Profile:

http://www.excelforum.com/member.php...o&userid=24233
View this thread: http://www.excelforum.com/showthread...hreadid=378465



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
subscript Bender Excel Discussion (Misc queries) 4 July 9th 09 07:45 AM
subscript Mark Subscript Excel Discussion (Misc queries) 0 March 28th 07 02:14 AM
subscript Elkar Excel Discussion (Misc queries) 0 March 27th 07 11:38 PM
Subscript out of Range Q John Excel Programming 5 December 14th 04 07:54 AM
Subscript out of range? Jason Hancock Excel Programming 3 May 26th 04 07:11 PM


All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"