• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Spreading a cell value evenly across a range of cells (eg, allocate annual to months)|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Spreading a cell value evenly across a range of cells (eg, allocate annual to months)|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosSpreading a cell value evenly acros…
sp_PrintTopic sp_TopicIcon
Spreading a cell value evenly across a range of cells (eg, allocate annual to months)
Avatar
Stephen Cotterill

New Member
Members
Level 0
Forum Posts: 2
Member Since:
September 13, 2019
sp_UserOfflineSmall Offline
1
September 13, 2019 - 11:54 am
sp_Permalink sp_Print

Dear People_Who_Know_More_Than_I

Can any of the gurus out there help me with a situation I have in an Excel worksheet?  I suspect it is a very basic question, but admit that so too are my skills with vba.

I want to take an annual budget figure and allocate it evenly across columns for each each month.  I want this to be triggered by the using press a button, because this allocation will not apply to all rows (only those where it is appropriate to allocate the budget evenly).  Because of this differing treatment for different rows, I think I cannot use regular formulae in the target (monthly) cells - thus trying to use vba.

So far I have manged to place buttons on my sheet and linked the following macro to a button:

Sub Spread_R7()
'
' Spread_R7 Macro
' Allocate annual budget evenly across all periods
''
Range("K7").Select
ActiveCell.FormulaR1C1 = "=R7C7/13"
Selection.AutoFill Destination:=Range("K7:W7"), Type:=xlFillDefault
Range("K7:W7").Select
End Sub

This seems to work just dandy for a single row (Row 7), but it would be pretty clunky to report this whole thing for every row.

So, I guess my question is, is it possible to do something 'dynamic' with the cell referencing so that a single macro can work on any row, perhaps taking its position from the row that the button sits in?

Any advice or assistance anyone can give will be gratefully received.

Thank you

SteveC.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
2
September 13, 2019 - 2:28 pm
sp_Permalink sp_Print sp_EditHistory

Hi Stephen

Give this a try.

Sub SpreadAllocation()
Dim r As Long
Dim c As Long
Dim cell As Range

For Each cell In Selection
r = cell.Row
Range("K" & r).Select
For c = 11 To 23
Cells(r, c).Formula = "=G" & r & "/13"
Next
Next
End Sub

You can attach the macro to a single button.

Just select any cell in a row and run the macro.

It will work for multiple selection too.

Good luck

Sunny

Avatar
Stephen Cotterill

New Member
Members
Level 0
Forum Posts: 2
Member Since:
September 13, 2019
sp_UserOfflineSmall Offline
3
September 16, 2019 - 9:14 am
sp_Permalink sp_Print

Hi Sunny

Thank you very much for your reply and suggestion:  I shall give that a go.

Best regards

SteveC.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ngoc Tinh
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6215
Posts: 27248

 

Member Stats:
Guest Posters: 49
Members: 31897
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.