LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Loop works for x = 1 but not for x = 2 : gets Type Mismatch error

I've included a portion of a Do loop below. It works (no Run Type Error 13,
Type Mismatch) for x = 1 but fails for x =2. The mismatch occurs on loop #2
with this statement highlighted: Range("$B$1").Value =
Cells(Range("$H$4").Value + x, "D").Value

The H4 cell contains a valid row number which was 270 for loop 1 and is now
271 for loop 2. The totalnumberofsessions value is 4. Here are the Watch
values at time of the failu
Watch : : Range("$B$1").Value : 7/4/2009 11:24:44 PM : Variant/Date :
Module18.ChartSessions
Watch : : Range("$H$4").Value : 269 : Variant/Double :
Module18.ChartSessions
Watch : : Range("$H$4").Value + x : 271 : Variant/Double :
Module18.ChartSessions
Watch : : x : 2 : Integer : Module18.ChartSessions

I would appreciate someone letting me know what I am doing wrong and how I
can get this to work. Thanks and have a good day.
Jim



' Cycle through all the sessions to process and print charts for each
individual session
Dim x As Integer
Dim totalnumberofsessions As Integer
totalnumberofsessions = Range("$F$4")
x = 1
Do While x <= totalnumberofsessions

Range("$B$1").Value = Cells(Range("$H$4").Value + x, "D").Value
Range("$C$2").Value = Cells(Range("$H$4").Value + x, "F").Value

*** working code here **************

x = x + 1
Loop
 
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
DoWhile Loop & Type mismatch error oakman[_27_] Excel Programming 4 June 27th 06 11:28 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Help - Type mismatch when running loop with strings from arrays Marie J-son[_5_] Excel Programming 3 March 19th 05 08:36 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Code works 1st time then Type Mismatch when checking for not blank cells Colleyville Alan Excel Programming 3 February 6th 04 05:21 AM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"