+ Reply to Thread
Results 1 to 7 of 7

Conditionally positioning arrays

Hybrid View

  1. #1
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Conditionally positioning arrays

    Are you looking for an automated copy and paste solution or a function that you put into the cells?


    can you explain some more?

  2. #2
    Registered User
    Join Date
    09-21-2009
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Conditionally positioning arrays

    I have set aside the maximun number of rows in the table and have currently set them to zero.

    I think I am looking for a function to go in the cells but really i am just looking for a way of getting the data in the cells so i can add em up.

    The situation is that i am creating small investments based on cash on hand and am trying to work out the income. So the cash on hand allows up to 3 loans per month for a maximun numberof 36 months. So there could be 108 loans but there could also be 0 loans.

    The numbers that i want to put in the rows are the loan returns per month (i know the value of that) and so I want a way of being able to create variable number of rows depending on that 0-3 number and to put the data in those rows - i think i can do that last part by use of index and column functions.

    I hope that helps

  3. #3
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Conditionally positioning arrays

    Hi Dave

    Assuming the data in A1:D1 and in A99 to the right as you wrote in your post, try:

    Try:

    Sub CopyShift()
    Dim rCopy As Range
    Dim lRow As Long, lCol As Long
    
    Set rCopy = Range("A99", Range("A99").End(xlToRight))
    
    lRow = 5
    For lCol = 1 To 4
        If Cells(1, lCol) <> 0 Then
            rCopy.Copy Cells(lRow, lCol).Resize(Cells(1, lCol), rCopy.Columns.Count)
            lRow = lRow + Cells(1, lCol)
        End If
    Next lCol
    End Sub

  4. #4
    Registered User
    Join Date
    09-21-2009
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Conditionally positioning arrays

    Works great - thanks - now all i have to do it get it to run when the data is changed. Are there things like 'execute subroutine on change of value' events in VBA?

+ 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