Consulting

Results 1 to 6 of 6

Thread: 2 excel questions

  1. #1

    2 excel questions

    Hi people!!!

    I'm a new guy in this forum and I need some help with two things..., pleaseeee
    In first place, in a Excel workbook, I need to run a macro in sheet 2 by click in a button on sheet 1. It seems to be very easy, but i've tried and so far I failed.
    The second thing is, inside that's macro code, select a range of cells, copy them and paste them to another sheet on the same workbook. The copy range varies in accordance to the input of the macro and the paste range also varies. I tried to do something like that:

    For t = 0 To Cells(2, 2)
    Cells(4, t).Select
    Cells(4, t).Copy_ Destination:=Sheets("Resultados").Range("A1").End(xlDown)
    Next t

    However, once again , an error occurs.

    Can you guys help me?
    Thanks in advance

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    The copy range varies in accordance to the input of the macro
    how is the copy range acquired?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    get rid of the underscore after copy also, you have for t = 0 To ... then Cells(4, t).Select - that will raise an error, use t = 1 To ...
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  4. #4
    Quote Originally Posted by lucas
    how is the copy range acquired?
    The copy range varies in terms of the number of columns that need to be copied to the other sheet. For example, in the input data for the macro, it has to be defined for how many "nodes" the calculations are executed. Therefore, the calculations are writed by the macro on the column AA to the column "X", where "X" depends of the number of "nodes" choosen before.

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi antony21,

    here's an example. One button is from the Control Toolbox toolbar the other is from the Forms toolbar. They are both found on the View/toolbars menu.

    The Code is commented but it basically finds the last row of data first and then does the copy/paste.

    Cheers,

    dr

  6. #6
    Quote Originally Posted by rbrhodes
    Hi antony21,

    here's an example. One button is from the Control Toolbox toolbar the other is from the Forms toolbar. They are both found on the View/toolbars menu.

    The Code is commented but it basically finds the last row of data first and then does the copy/paste.

    Cheers,

    dr
    Thanks rbrhodes, you're the man!

    Cheers

Posting Permissions

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