Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Type Mismatch Error


  • Please log in to reply

#1
beethoven

beethoven

    Member

  • Member
  • PipPip
  • 92 posts
I have the following code:

Sub Quicky()
If Worksheets("Daily").Range("B13").Value = 4 Then
Range("B13:H13").Merge
Range("B13") = "Due " & Range("B13").Value & " times"
End If
End Sub


This code works just fine, but if I change Range("B13") in the first line to Range("B11:B13") I get a type mismatch error. I don't know why. Any suggestions?
  • 0

Advertisements


#2
IO-error

IO-error

    Member

  • Member
  • PipPipPip
  • 276 posts
You want:
Range("B11:B13")

Try:
Range("C13:B13")

If that does work, you might know the problem.
Sorry that I'm not giving more detailed suggestions, but I don't know if your a student that wants to skip work or a worker that wants to skip learning.

Good luck.
  • 0

#3
beethoven

beethoven

    Member

  • Topic Starter
  • Member
  • PipPip
  • 92 posts
I do not really understand the problem, apart from Range not working with multiple cells (why I don't know). I would just like the code given to work with more than one cell at a time. I am a student who is learning VBA and sometimes aspiring a bit too high too fast and getting stuck. I'm not trying to skip either work or learning but would like to solve this problem. ("C13:B13") same problem.
  • 0

#4
IO-error

IO-error

    Member

  • Member
  • PipPipPip
  • 276 posts
Okay, you now know that merging doesn't work on cells.
But something that could work is reading the cells and giving it a variable and then get this kind of idea.

VarA = B13.Value
VarB = B11.Value
VarC = VarA+VarB
VarD = "Due " & VarC.Value & " times"


***EDIT
If it doesn't work, don't give up, just come for help again.

Edited by IO-error, 09 March 2007 - 06:12 AM.

  • 0

#5
beethoven

beethoven

    Member

  • Topic Starter
  • Member
  • PipPip
  • 92 posts

Okay, you now know that merging doesn't work on cells.
But something that could work is reading the cells and giving it a variable and then get this kind of idea.

VarA = B13.Value
VarB = B11.Value
VarC = VarA+VarB
VarD = "Due " & VarC.Value & " times"


***EDIT
If it doesn't work, don't give up, just come for help again.



The merging works just fine, but the whole code breaks down if I try to apply it to more than one cell at a time.
  • 0

#6
ChrisWright

ChrisWright

    Member

  • Member
  • PipPip
  • 34 posts
I think part of the problem is similar to one I was experiencing once.


The problem as I see it is that you are trying to compare a single value, vs a range.


I'm quite a beginner with VB and VBA myself, but if you PM me general information on what you are trying to do, I will get back to you as soon as possible, and will likely find a solution (even if it is long winded!)

Chris
  • 0

#7
beethoven

beethoven

    Member

  • Topic Starter
  • Member
  • PipPip
  • 92 posts
Thanks for your offer, but I actually just got the problem solved over at Ozgrid. Thanks anyway though for everybody's help!

Edited by beethoven, 12 March 2007 - 06:12 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP