+ Reply to Thread
Results 1 to 4 of 4

Cells with a column defined by variable

  1. #1
    Registered User
    Join Date
    03-20-2014
    Location
    Poland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Cells with a column defined by variable

    Hi,

    I am using code as below in order to define column as a variable. While it works with defining the row pretty well it fails with the column despite the same method.

    with the code below:

    Dim wiersz As String
    wiersz = 34
    Cells(37, wiersz) = "cos"

    I am getting the error message "Runtime error '1004': Application-defined or object-defined error"

    with the this code everything is fine, do you know why?

    Dim wiersz As String
    wiersz = 34
    Cells(wiersz, 37) = "cos"

    regards,

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,339

    Re: Cells with a column defined by variable

    Dim them as Long


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-20-2014
    Location
    Poland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Cells with a column defined by variable

    It works fine, thanks!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,339

    Re: Cells with a column defined by variable

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create a defined number of copied cells for values found in a column
    By S.Taylor in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 11-08-2013, 04:25 AM
  2. Macro to Insert defined integer into range defined by variable criteria
    By stereofeedback in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2013, 12:33 PM
  3. Variable not defined error when I have defined the variable
    By jeffadkisson in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-27-2012, 07:00 PM
  4. Obtaining column/row numbers of cells in user defined function
    By GreenInIowa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2005, 05:05 PM
  5. [SOLVED] Sum cells based on a row variable and seperate column variable
    By CheeseHeadTransplant in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-23-2005, 02:05 PM

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