Dynamic Autofill

  • Hi, I'm struck in VBA code to find number of rows after fetching the data from another workbook and autofill.


    Macro placed in separate file Dumhost.xlsm( Macro workbook) to update Dummy format.csv (File1) from Xando.csv work (file2).



  • Your code finds the last row in wb1.


    Is this what you mean?


  • That line of code is from your code not what I added.


    What error are you getting?


    My code simply tells you how many lines are in the expanded data, I have no idea what you actually want.

  • You are getting that error because your code is assigning a Range to a Workbook Object, Workbooks do not have Ranges, Worksheets do. You need to specify a Worksheet in that Workbook, for example

    Code
    Lastrow = wb1.Sheets("Sheet Name" or Sheet Index).Range("B" & Rows.Count).End(xlUp).Row

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome. Thanks for the "Like".

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Code
    .Cells(2, lh) = Application.VLookup(.Cells(2, 7), x, 2, False)

    KjBox  royUK

    I require lookup code to be filled down but its returning same value for all the cells. Can anyone tell me what I'm missing here..

  • Thanks for the files you sent.


    First you need to change the Input file a bit, replace "Dom Rep" with "Dominican Republic" and replace "Trinidad & Tobago" with "Trinidad and Tobago"


    Then change your code to this

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

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