+ Reply to Thread
Results 1 to 8 of 8

Copy/populate rows based on variable cell values

Hybrid View

  1. #1
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Copy/populate rows based on variable cell values

    Hi,

    I need to populate sheet2 based on values in sheet1. sheet1 A1 represents a starting value. Sheet1 A2 & A3 represent values reflected on sheet2. Sheet1 A5 is the number of rows to be produced on sheet2. Sheet1 A4 determines if the top two rows are produced. All other text on sheet 2 is constant.

    Ideally, sheet2 would automatically be saved as "funclocs.txt" on the desktop in text tab delimited format, but this is not necessary if it's difficult to code.

    Thanks in advance,
    Matt
    Attached Files Attached Files
    Last edited by matchooo; 05-30-2013 at 02:45 PM.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Copy/populate rows based on variable cell values

    try funclocs.xlsm
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Copy/populate rows based on variable cell values

    Fantastic! It looks great!

    I wasn't clear about the first two rows. If A4 is set to "New", the first two rows on sheet 2 need to be created as they appear in attached workbook. It works just fine for Addl.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Copy/populate rows based on variable cell values

    like this? funclocs.xlsm

  5. #5
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Copy/populate rows based on variable cell values

    You are a genius! Thank you, sir!

  6. #6
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Copy/populate rows based on variable cell values

    Sorry, If I select Addl, it will leave row 1 blank :-(

  7. #7
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Copy/populate rows based on variable cell values

    Another try: funclocs.xlsm

  8. #8
    Registered User
    Join Date
    03-18-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Copy/populate rows based on variable cell values

    I integrated it into a different workbook and tweaked it a little. I modified the code for the second button so it would not affect the original worksheet:
    Private Sub CommandButton2_Click()
    Dim DTAddress As String
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator

    Dim wb As Variant
    Dim newwb As Variant
    Set wb = ActiveWorkbook
    Set newwb = Workbooks.Add()
    Application.DisplayAlerts = False
    ThisWorkbook.Worksheets("funclocs").Activate
    wb.ActiveSheet.Copy newwb.ActiveSheet 'copy sheet to new workbook
    newwb.ActiveSheet.Activate
    ActiveSheet.UsedRange
    newwb.SaveAs Filename:=DTAddress & "funclocs.txt", _
    FileFormat:=xlText, _
    CreateBackup:=False
    ActiveWorkbook.Close savechanges:=False
    Application.DisplayAlerts = True
    ThisWorkbook.Worksheets("Order").Select

    End Sub

    Thanks a ton!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1