Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:38:49+00:00 2026-06-10T13:38:49+00:00

I have only recently started picking up VBA in excel and I have been

  • 0

I have only recently started picking up VBA in excel and I have been going through various tutorials online but I have encountered a bit of a problem when getting to if statements. Based on the knowledge i have gained online and from my VB knowledge i came up with the following code.

Private Sub CommandButton1_Click()
   Dim mynum As Integer, checker As String
   mynum = Range("A1:A10").value

   If mynum > 0 Then
        checker = "check"
   Else
        checker = "missing"
   End If

   Range("B1:B10").value = checker
End Sub

The idea is that if there is a number over 0 in column a, the adjacent cell in column b is checked, if however its 0 or lower the adjacent cell says missing (if that makes any sense) theres no real point to this as I am learning the basics at the moment 🙂

Now my problem…basically when i attempt to debug this, I get the Type Mismatch error and i cant really see why this is so. I know that it works when i set the range as one cell rather than multiple cells so my best guess is that it has something to do with that. I have looked into it but again im getting results that only back up that this should work. I must have misread it somewhere but help would be appreciated. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:38:50+00:00Added an answer on June 10, 2026 at 1:38 pm

    You cannot Assign/Check values of range like this for what you are trying to do. One way would be to loop through your range. For Example

    Private Sub CommandButton1_Click()
        Dim Rng As Range, aCell As Range
    
        Set Rng = Range("A1:A10")
    
        For Each aCell In Rng
            If aCell.Value > 0 Then
                aCell.Offset(, 1).Value = "check"
            Else
                aCell.Offset(, 1).Value = "missing"
            End If
        Next
    End Sub
    

    EDIT

    BTW, you don’t need VBA for this. If you are open for a Non VBA solution then simply put this formula in Cell B1 and copy it down

    =IF(A1>1,"Check","Missing")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have only recently started using CakePHP and have been unable to get validation
I have only started learning python recently. I would still be considered a beginner.
I have only started learning Python recently. Let me explain what I am trying
I have only recently been introduced to curl and am working on a certain
I have an iPhone app, which is running only in landscape mode, but recently
I have only recently started programming significantly, and being completely self-taught, I unfortunately don't
Sorry if this is a simple question, but I've only recently started learn coding
I have a project that I have recently started working on seriously but had
I have a weird problem that only started recently. When I run the app
I have only started programming in VB recently and I am not very good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.