dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] VBA error - please help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Location
    London
    Posts
    1

    Resolved [RESOLVED] VBA error - please help

    Hi guys,

    Please can someone help me with my code below?I'm quite new, so not sure where is the issue.

    I am trying to copy a Column in one sheet (the length of the column is not always the same so I am using "Rows.Count"), then select this range, copy it and paste special values on a specific cell of another sheet!

    Many thanks in advance

    Private Sub CommandButton1_Click()

    Dim sh As Worksheet
    Dim k As Integer
    Dim rng1 As Range

    Set sh = Worksheets("Sheet1")

    k = sh.Range("A1", sh.Range("A9").End(xlDown)).Rows.Count

    rng1.Value = Range(Cells(9, 1), Cells(k, 1)).Value

    rng1.Select

    Selection.Copy

    Worksheets("Sheet2").Range("A2").PasteSpecial xlPasteValues

    End Sub

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,541

    Re: [RESOLVED] VBA error - please help

    You never set rng1

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width