+ Reply to Thread
Results 1 to 3 of 3

Problem with Distribution Code

Hybrid View

Nisha_NishaDelhi Problem with Distribution Code 05-06-2014, 04:02 PM
AB33 Re: Problem with Distribution... 05-06-2014, 04:20 PM
AB33 Re: Problem with Distribution... 05-06-2014, 04:25 PM
  1. #1
    Registered User
    Join Date
    04-23-2014
    Location
    Delhi
    MS-Off Ver
    Excel 2003
    Posts
    25

    Problem with Distribution Code

    Dear VBA Experts
    I have written a code for equal distribution of Budget Data based on condition.

    The user will enter annual budget number in Column K (highlighted in Green) and based on condition in Column N (highlighted in Yellow), the data will be divided by 12 and it need to be equally distributed from Colum P to Column AA. The condition for distribution is ‘Y’ (Yes)/ ‘N’ (No).

    I have also attached the sample file.Budget_Input Form.xlsm

    Sub BudDist()
    Dim myCell As Range
    Dim Data As Long
    Dim lr As Long
    Dim a
    
    lr = Cells(Rows.Count, 11).End(xlUp).Row
    For Each myCell In Range("K39:K" & lr)
    If UCase(myCell.Offset(, 3).Value) = "Y" Then
        Data = myCell.Value / 12
        a = myCell.Row
        Range("P" & a & ":AA" & a).Value = Data
        End If
    
    Next myCell
    
    End Sub
    Please help me with fixing this issue.

    Thanks,
    Nisha

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with Distribution Code

    Option Explicit
    Sub BudDist()
    Dim myCell As Range
    Dim Data As Long
    Dim lr As Long
    Dim a
    
    lr = Cells(Rows.Count, 11).End(xlUp).Row
    For Each myCell In Range("K39:K" & lr)
    If UCase(Trim(myCell.Offset(, 3).Value)) = "Y" Then
        Data = myCell.Value / 12
        a = myCell.Row
        Range("P" & a & ":AA" & a).Value = Data
        End If
    
    Next myCell
    
    End Sub

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with Distribution Code

    If you want round figure, you can change this line

    Dim Data As Double

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error with distribution code
    By Nisha_NishaDelhi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-06-2014, 04:32 PM
  2. Problem with NORMSDIST and distribution of hours
    By RE_NERO in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-31-2014, 10:29 PM
  3. [SOLVED] Freq distribution problem
    By Mirisage in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 05-23-2013, 08:41 PM
  4. Distribution problem
    By Diandude in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 09:48 AM
  5. VBA Code for a Distribution
    By moroformat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2009, 08:32 PM

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