|
-
Jan 19th, 2006, 11:56 PM
#1
Thread Starter
Addicted Member
Problem in excel VBA coding **RESOLVED**
Hi all,
I did the following coding for retrieving some vaues from a excel sheet but I am facing problem in the red colour line "IsEmpty".
Run-Time error '1004':
Method 'Worksheets' of object '_Global' failed
I am doing this in VB 6.0 (Not in Excel)
Help please.
advance
Thanks
Raj
VB Code:
[FONT=Courier New]Sub RetValFrmxl(ChuckTyp As String, Ports As String)
Dim XlApp1 As Object
Dim XlApp As Object
Dim ExcelWasNotRunning As Boolean
Dim ActSht As Excel.Worksheet
Dim i, j, k As Long
Set XlApp1 = GetObject(App.Path & "\data.XLS")
XlApp1.Application.Visible = True
XlApp1.Parent.Windows(1).Visible = True
XlApp1.Worksheets(Ports).Activate
Set ActSht = XlApp1.ActiveSheet
i = 1
j = 0
[COLOR=Sienna] Do While Not IsEmpty(Worksheets(Ports).Cells(i, 1))[/COLOR]
If ActSht.Cells(i, 1).Value = "" Then
Exit Do
End If
If ActSht.Cells(i, 1).Value = ChuckTyp Then
For j = 2 To 8
If j = 2 Then
A = ActSht.Cells(i, j).Value
Debug.Print A
ElseIf j = 3 Then
B = ActSht.Cells(i, j).Value
Debug.Print B
ElseIf j = 4 Then
C = ActSht.Cells(i, j + 1).Value
Debug.Print C
ElseIf j = 5 Then
D = ActSht.Cells(i, j + 2).Value
Debug.Print D
ElseIf j = 6 Then
E = ActSht.Cells(i, j + 2).Value
Debug.Print E
ElseIf j = 7 Then
F = ActSht.Cells(i, j + 2).Value
Debug.Print F
ElseIf j = 8 Then
G = ActSht.Cells(i, j + 2).Value
Debug.Print G
End If
Next
End If
i = i + 1
Loop
If ExcelWasNotRunning = True Then
XlApp.Application.Quit
End If
Set XlApp = Nothing
End Sub[/FONT]
Last edited by thiru_rajamani; Jan 20th, 2006 at 02:09 AM.
Thanks
Raj
-
Jan 19th, 2006, 11:59 PM
#2
Re: Problem in excel VBA coding
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2006, 12:03 AM
#3
Re: Problem in excel VBA coding
This worked fine for me in a test book.
VB Code:
Dim Ports As String
Dim i As Integer
i = 1
Ports = "Sheet1"
Do While Not IsEmpty(Worksheets(Ports).Cells(i, 1))
MsgBox "Not empty"
Loop
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2006, 02:09 AM
#4
Thread Starter
Addicted Member
Re: Problem in excel VBA coding
This done the trick
Do While Not IsEmpty(ActSht.Cells(i, 1))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|