Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 22nd, 2006, 03:50 AM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Method Range - VBA - Excel

Hello everyone, I hope someone here can help me, I wrote this for an excel report, but I am getting a runtime error "1004" "Method 'Range' of object 'Worksheet' failed" whatever that means! The debugger points to the line I have put in bold. But I can't figure out why it would point out that since I have already used a similiar line.

Public Sub TheBigKahuna()
Dim Row1 As Integer, Row2 As Integer, Col1 As Integer, Col2 As Integer, Count As Integer
Col1 = 1
Col2 = 1
Row2 = 2
For Row1 = 2 To 9594
    Sheet2.Range("A" & Row2, "Q" & Row2).Value = Sheet1.Range("A" & Row1, "Q" & Row1).Value
    Col1 = 18
    Col2 = Col1 + 14
    For Count = 1 To 4
        Sheet2.Range(Chr(Col1 + 97) & Row2, Chr(Col2 + 97) & Row2).Value = Sheet1.Range(Chr(Col1 + 97) & Row1, Chr(Col2 + 97) & Row1).Value
        Col1 = Col1 + 14
        Col2 = Col2 + 14
        Row2 = Row2 + 1
    Next Count
    Col1 = 1
    Col2 = 1
Next Row1
MsgBox "Complete", vbOKOnly, "Report"
End Sub



Everytime you click start a penguin dies!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Method 'Range' of _Global' Failed accessing Excel Socko Beginning VB 6 0 January 29th, 2008 09:33 AM
VBA Macro FIND THIS MONTH in a given range mvatoi Excel VBA 3 August 24th, 2007 08:12 AM
METHOD 'RANGE' OF OBJECT '_GLOBAL' FAILED CBCHIAM Excel VBA 7 August 31st, 2005 04:08 AM
XL/VBA:Why do I get this error(Range.FormulaR1C1)? PaLPiTaTioN Excel VBA 3 January 3rd, 2005 08:27 AM
Excel VBA: Select range of data and plot chart? xitu Excel VBA 1 December 23rd, 2003 04:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.