Import codes from once sheet to the other

  • Re: Import codes from once sheet to the other


    Hi.. a sample workbook in an excel forum is ALWAYS more preferred than an image..


    Plus you chopped off the column and row numbers..


    In any case.. something like this.. adapt as needed..


    Code
    Private Sub CommandButton1_Click()
    Dim x, i As Long, cnt As Long
    x = Application.Transpose(Sheets(2).Range("A2:A" & Sheets(2).Range("A" & Rows.Count).End(xlUp).Row))
    cnt = 1
    For i = LBound(x) To UBound(x)
     Sheets(1).Cells(i + cnt, 1).Value = x(i)
     cnt = cnt + 24
    Next i
    End Sub
  • Re: Import codes from once sheet to the other


    Hi. This is not working - please advise what I am doing wrong.
    https://1drv.ms/x/s!AskK8ngh660bgbNuooNMWwBsaWCc0w


    The data from sheet: "SubstoreBuyPlan" should show in every 25th row in "SubstoreProductMaster"


  • Re: Import codes from once sheet to the other


    Hi..


    Please put code tags around any code you post. (When in the Reply box.. highlight your code and click the little # icon in the Reply box menu bar). I have done it for you in your last post.


    Code
    Sub ImportProdCode()
        Dim x, i As Long, cnt As Long
        x = Application.Transpose(Sheets("SubstoreBuyPlan").Range("A2:A" & Sheets("SubstoreBuyPlan").Range("A" & Rows.Count).End(xlUp).Row))
        cnt = 1
        For i = LBound(x) To UBound(x)
            Sheets("SubstoreProductMaster").Cells(i + cnt, 1).Value = x(i)
            cnt = cnt + 24
        Next i
    End Sub


    You had a couple of issues when you adapted the code i gave you.


    1. The way you are referencing your Worksheets would require you to Declare and Set them first. I may have confused you in that the way I referenced them in the initial code was by the sheets index number. IN the second code I show how to reference it by sheet name (one way)..


    2. Your missing the part where you should turn screenupdating to False at the start of your code.


    3. Not that I think you need to do this.. but you are setting the calculation mode to automatic at the end but not setting it to manual at the start.. so it is pointless.


    Lemme know how you go.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!