Posts by Ken Santopietro

    Embarking on a project to write macro to take financial analysis figures from sheet in excel and to place selected data in a table in a Word document.
    This will save preparation and keying figures twice.
    I have not seen this done so I am looking for "head start" code to modify for my situation. Thank you, Ken

    Re: Vbs copy cells into named range table


    Hello RoyUK,
    I created a table on my second tab, and I messed up the first macro. I tried to use the name of it, but I'm getting busted.
    On the second macro, now that there is a table, I desperately need assistance to add the information to that table.
    I read what you suggested first and I did that and know I am closer, but still inoperable, if you can take another look. Much thanks.
    Ken

    I have sheet1 where I have person key in bid information, 1 row, 11 columns of data.


    They may key up to 5 bid lines.


    I want to hit a macro button and have these lines inserted at the end of the named data range on sheet2. On sheet2, I call it "BIGBIDLIST"


    I have been looking for samples to get started with code, but all of them used unfamiliar terms.


    Any help on getting started would be great. Thank you. Ken

    Re: Variable sheet reference and dynamic copy references


    I really appreciate it. but I plugged it in and.. the paste line just sticks.. nothing pastes still.


    Code
    For Each ws In Worksheets
            Select Case ws.Name
            Case "ARS", "AUD", "CAD"
                 'ws.Activate
                ws.Range(ws.Range("D24").Value, ws.Range("D25").Value).Copy
                ws[COLOR=#00FF00].Range(ws.Range("B24").Value, ws.Range("B25").Value).PasteSpecial xlValues[/COLOR]
                ws.Range(ws.Range("B24").Value, ws.Range("B25").Value).PasteSpecial xlPasteColumnWidths
            End Select
        Next ws

    Re: Variable sheet reference and dynamic copy references


    Okay. I changed to Name, now it stops at the copy step. This update was made to the vba in the sample worksheet I posted. See anything else? Sorry to trouble.


    Re: Variable sheet reference and dynamic copy references


    Thanks!
    I now get an error with the "Sheet " & x. You see, Sheet3 is called ARS, Sheet4 is called AUD, etc.
    But I wanted to loop through, and I thought that I read that you could still, in VBA, call them by the Sheet numbers. A simple thing has become a problem. Thanks so much for your help with Range.
    Ken

    I have sheets named after currencies, like USD, CAN...
    I want to loop through them referring to them as Sheet3, Sheet4, etc. because I thought I can.
    There is a cell reference, like "AC1" in a cell, and it will be the beginning of the copy range.
    Then I want to use another cell reference, like "AE1" in a cell, and it will be the beginning of the paste range.
    I cannot get this code to stop debugging.


    Thank you.

    Re: must reference sheet1, sheet2, not sheet names


    Thanks -- I was trying to modify this original..


    When it worked it was copying one range to all of the sheets. I needed to copy a variable range from sheet3, sheet4, etc. onto a variable spot on the same sheets. I have the variable ranges on sheet1.
    Thanks.

    I want to ignore sheet names and instead reference sheets in a loop as sheet1, sheet2
    My sheet names have codes that are good for the user to pick from quickly, but not for my simple coding skills


    my vba doesn't work.

    Code
    loop through data sheets copying an area of known data
          For x = 3 To 15
          Sheets("Sheet " & x).Select
              Range(Sheet1.Range(Cells((42 + x - 3), 6).Value, Cells((42 + x - 3), 7).Value)).Copy
                 Sheets(CStr(rSheets(x, 1))).Cells(3, CStr(rSheets(x, 2))).PasteSpecial xlValues
                 Sheets(CStr(rSheets(x, 1))).Cells(3, CStr(rSheets(x, 2))).PasteSpecial xlPasteColumnWidths
          Next x

    Re: Fix loop for cell reference totally stuck


    Can you take another look?


    latest effort for this..




    What it does is copy from current sheet onto the other sheets.
    That is not what I want.
    I want to copy from sheet 3 (an area per the chart on sheet 1) to an adjacent area on sheet 3,
    then do it again, from sheet 4, 5, 6 etc. through 15.
    Cannot figure, and already uploaded worksheet.
    Ken

    Re: Fix loop for cell reference totally stuck


    Sheet1 is actually named USD.
    It has a table on it (each column is a calculated reference to a Cell on another Sheet)
    for sheets 3 to 15, I have to copy four columns from sheets 3 to 15, and paste to other columns on sheets 3 to 15.
    The references of what columns to copy and where to paste are on this table on Sheet1.
    Doing this is the crux of the problem.
    Ken


    Table on Sheet1.


    [TABLE="width: 422"]

    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    Sheet #

    [/td]


    [td]

    Sheet

    [/td]


    [td][/td]


    [TD="colspan: 2"]Dependent of this sheet[/TD]

    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td]

    NAME

    [/td]


    [td]

    Copy to

    [/td]


    [TD="colspan: 2"]Copy ranges on sheets[/TD]

    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td]

    on sheets

    [/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    3

    [/td]


    [td]

    ARS

    [/td]


    [td]

    PX

    [/td]


    [td]

    PT1

    [/td]


    [td]

    PW18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    4

    [/td]


    [td]

    AUD

    [/td]


    [td]

    PX

    [/td]


    [td]

    PT1

    [/td]


    [td]

    PW18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    5

    [/td]


    [td]

    BRL

    [/td]


    [td]

    QA

    [/td]


    [td]

    PW1

    [/td]


    [td]

    PZ18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    6

    [/td]


    [td]

    CAD

    [/td]


    [td]

    PZ

    [/td]


    [td]

    PV1

    [/td]


    [td]

    PY18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    7

    [/td]


    [td]

    CNY

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    8

    [/td]


    [td]

    EUR

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    9

    [/td]


    [td]

    JPY

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    10

    [/td]


    [td]

    MXN

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    11

    [/td]


    [td]

    NZD

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    12

    [/td]


    [td]

    RUB

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    13

    [/td]


    [td]

    SEK

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    14

    [/td]


    [td]

    ZAR

    [/td]


    [td]

    QA

    [/td]


    [td]

    PW1

    [/td]


    [td]

    PZ18

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    15

    [/td]


    [td]

    INR

    [/td]


    [td]

    PU

    [/td]


    [td]

    PQ1

    [/td]


    [td]

    PT18

    [/td]


    [td][/td]


    [/tr]


    [/TABLE]