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

  • Home
  • SEARCH
  • 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 5977165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:19:53+00:00 2026-05-22T21:19:53+00:00

I defined the following subroutine: Sub EnterCellValueMonthNumber(cells As range, number As Integer) range(cells).Select ActiveCell.FormulaR1C1

  • 0

I defined the following subroutine:

Sub EnterCellValueMonthNumber(cells As range, number As Integer)

range(cells).Select
ActiveCell.FormulaR1C1 = number

End Sub

When I call the subroutine like this:

EnterCellValueMonthNumber ("N23:Q23",1)

I get the following error message:

Compile error Expected: =

I have no idea why I get this message. Does anyone know what I am missing?

  • 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-05-22T21:19:54+00:00Added an answer on May 22, 2026 at 9:19 pm

    You would call the sub as

    EnterCellValueMonthNumber "N23:Q23", 1
    

    No brackets. Or

    Call EnterCellValueMonthNumber("N23:Q23", 1)
    

    Brackets, and Call before it.

    Also, your Sub is expecting a Range object as the first argument and you’re supplying a string; you should change the signature of the sub to:

    Sub EnterCellValueMonthNumber(cells As String, number As Integer)
    

    Also, I’m uncertain as to what you are trying to achieve with this code as it will only set the top-left cell of the range to 1. Would something like

    Range(cells).Value = number
    ' Or, if you're going to be passing in something more complex later...
    Range(cells).FormulaR1C1 = number
    

    be more appropriate?

    I’d also be very wary of using Range("...") without specifying which sheet you are referring to. This will act on whichever is the active sheet and can thus cause unexpected problems, almost always prefer SheetX.Range("..."). Similarly for using .Select, it’s unnecessary, and can only cause problems for you in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select data from a table defined similar to the following :
I have defined the following variable: myVar=true now I'd like to run something along
I have the following members defined in a class that I'm trying to deserialise:
So I have the following user defined type in my oracle database: CREATE OR
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
The following snippet is supposed to take the value of PROJECT (defined in the
With a vector defined as std::vector<std::string> , Wondering why the following is valid: if
I keep the name of the subroutine I want to call at runtime in
I have encountered a difficulty in understanding the subroutine syntax. using the following code:
I have defined the following struct to represent an IPv4 header (up until the

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.