Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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