Consulting

Results 1 to 2 of 2

Thread: pasting range .offset

  1. #1
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location

    pasting range .offset

    I have to copy a number of columns from a different file to re-align them. I have a userform that initialize with the default column letter.

    [VBA]Private Sub UserForm_Initialize()
    TextBox1.Value = "A" ' EPD number
    TextBox2.Value = "C" ' revision[/VBA]

    'and so on

    i want to copy each of those column over to the worksheet with this code:

    [VBA]
    Sub workbooksetup()
    Dim file path as string
    dim wkbmacro as workbook, wkbcognos as workbook
    dim i as long

    filepath = "file path*"
    Set wkbmacro = ThisWorkbook
    On Error Resume Next
    Application.DisplayAlerts = False
    Set wkbcognos = Application.Workbooks.Open(filepath)
    Application.DisplayAlerts = True


    If Not Range("A1").Value = "EPD Number" Then
    Range("1:7").Delete
    End If

    usedcell = 65536 - Application.WorksheetFunction.CountBlank(Range("A:A")) + 100
    MsgBox (usedcell)
    For i = 1 To 14
    Range(agingcars("textbox" & i).Value & "1:" & agingcars("textbox" & i).Value & usedcell).Copy

    ' i got it to this point but it doesn't copy over, can someone help me.

    wkbmacro.Activate
    Range("A1").Offset(, i).Paste
    wkbcognos.Activate
    Next
    [/VBA]

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I think this is your problem if I understand correctly:
    [VBA]
    Range("A1").Offset(, i).Paste
    [/VBA]

    did you just paste it to range A1 to actually see if it is copying to begin with?

    What is your objective in the paste operation? To put it in the column from which it was copied?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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