Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type Mismatch for a formula


Sheet1.Cells(11, col_Safety).Value = "=IF(INT(F11)=1,("
+ Sheet1.Cells(7, col_Safety) + "+(MOD(F11,1)*"
+ Sheet1.Cells(7, col_Safety + 1) + ")),IF(INT(F11)=2,("
+ Sheet1.Cells(7, col_Safety + 1) + "+"
+ Sheet1.Cells(7, col_Safety + 2) + "+(MOD(F11,1)*"
+ Sheet1.Cells(7, col_Safety + 2) + "))))"

This formula keeps on giving me a Type Mismatch error...
I'm using this in a macro instead of a formula because this is a weekly
schedule and I don't want the numbers changing when it's not the current
date.

Can anyone see why I'm getting this error?

Any help will be greatly appreciated!

TIA

:)


--
cultgag
------------------------------------------------------------------------
cultgag's Profile: http://www.excelforum.com/member.php...o&userid=22677
View this thread: http://www.excelforum.com/showthread...hreadid=525835

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Type Mismatch for a formula

Try using & to concatenate text and use + to add numbers:

Option Explicit
Sub testme01()
Dim myFormula As String
Dim col_Safety As Long
col_Safety = 8
myFormula = "=IF(INT(F11)=1,(" _
& Sheet1.Cells(7, col_Safety) & "+(MOD(F11,1)*" _
& Sheet1.Cells(7, col_Safety + 1) & ")),IF(INT(F11)=2,(" _
& Sheet1.Cells(7, col_Safety + 1) & "+" _
& Sheet1.Cells(7, col_Safety + 2) & "+(MOD(F11,1)*" _
& Sheet1.Cells(7, col_Safety + 2) & "))))"

Debug.Print myFormula
End Sub

And with some test data in those cells, I got a formula like:

=IF(INT(F11)=1,(6+(MOD(F11,1)*17)),IF(INT(F11)=2,( 17+8+(MOD(F11,1)*8))))

And I'm not sure that's correct, either.

cultgag wrote:

Sheet1.Cells(11, col_Safety).Value = "=IF(INT(F11)=1,("
+ Sheet1.Cells(7, col_Safety) + "+(MOD(F11,1)*"
+ Sheet1.Cells(7, col_Safety + 1) + ")),IF(INT(F11)=2,("
+ Sheet1.Cells(7, col_Safety + 1) + "+"
+ Sheet1.Cells(7, col_Safety + 2) + "+(MOD(F11,1)*"
+ Sheet1.Cells(7, col_Safety + 2) + "))))"

This formula keeps on giving me a Type Mismatch error...
I'm using this in a macro instead of a formula because this is a weekly
schedule and I don't want the numbers changing when it's not the current
date.

Can anyone see why I'm getting this error?

Any help will be greatly appreciated!

TIA

:)

--
cultgag
------------------------------------------------------------------------
cultgag's Profile: http://www.excelforum.com/member.php...o&userid=22677
View this thread: http://www.excelforum.com/showthread...hreadid=525835


--

Dave Peterson
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
Type Mismatch?? Otto Moehrbach Excel Programming 4 December 28th 05 03:03 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
type mismatch--how to fix rroach Excel Discussion (Misc queries) 2 July 14th 05 06:23 PM
Type Mismatch Phil Hageman[_3_] Excel Programming 2 January 9th 04 06:11 PM


All times are GMT +1. The time now is 12:54 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"