+ Reply to Thread
Results 1 to 5 of 5

Macro Help (pasting values into several columns)

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Macro Help (pasting values into several columns)

    itemPrice is a number that is inputted by the user. I want this number to be pasted on several columns (C to N) on a specific user inputted row. Running this gives me an application-defined or object-defined error due to "Range(Cells(theRow, C)).Value = itemPrice".


    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro Help (pasting values into several columns)

    juliorevka,

    It looks like its because your code is referencing a variable C and a variable N instead of giving the Cells() statement the string values "C" and "N" for the column letters. Put quotation marks around "C" and "N"
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro Help (pasting values into several columns)

    Try:

    Please Login or Register  to view this content.
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro Help (pasting values into several columns)

    Adding a quotation marks made a different type of error appear, but Domski's code worked.

    How exactly do the "&" signs within range work?
    Last edited by juliorevka; 03-05-2012 at 12:24 PM.

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro Help (pasting values into several columns)

    They concatenate the various parts into a single string like Range("C2:N2")

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1