Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 November 21st, 2011, 06:36 AM
Authorized User
 
Join Date: Oct 2011
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default Run time error 5992

Hi,

I am trying to iterate through the cells in column in a table. If the table has merged column cells then I get the following error

Run time error 5992
Cannot access individual columns in this collection because the table has
mixed cell widths.

Is there a way I can avoid this error while iterating through cells?
 
Old November 22nd, 2011, 04:38 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

How are you iterating the cells

Is it through any method as shown below

Code:
For i = 3 To 9
    MsgBox Cells(2, i).Value
Next i
For Each ocell In Range("A2:g2")
    MsgBox ocell.Value
Next ocell
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old November 23rd, 2011, 02:19 AM
Authorized User
 
Join Date: Oct 2011
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Post

Quote:
Originally Posted by Shasur View Post
Hi

How are you iterating the cells

Is it through any method as shown below

Code:
For i = 3 To 9
    MsgBox Cells(2, i).Value
Next i
For Each ocell In Range("A2:g2")
    MsgBox ocell.Value
Next ocell
Cheers
Shasur
Hi,

You are right
I am trying to access the value in the cell by something like

For i = 3 To 9
MsgBox Cells(2, i).Value
Next i

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM





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