Writing Macros in Excel

%3CLINGO-SUB%20id%3D%22lingo-sub-1600583%22%20slang%3D%22en-US%22%3EWriting%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1600583%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20create%20a%20macro%20in%20Excel%202013%20through%20Developer.%20I%20need%20to%20be%20able%20to%20have%20it%20take%20information%20from%20multiple%20cells%20on%20Sheet%201%20for%20a%20date%20that%20is%20recorded%20in%20the%20A%20column%20with%20the%20months%20across%20the%20top%20on%20the%20A%20row.%20I%20need%20them%20to%20take%20information%20put%20in%20column%20F%20and%20add%20it%20together%20and%20put%20it%20in%20the%20proper%20cell%20on%20Sheet%204%2C%20where%20it%20can%20be%20shown%20as%20a%20total.%20I'm%20not%20sure%20how%20to%20write%20a%20macro%20that%20would%20be%20able%20to%20do%20that%20for%20multiple%20pieces%20of%20information%20that%20need%20to%20consolidated%20on%20different%20sheets%20in%20my%20workbook.%20Please%20help.%20I'm%20working%20with%20different%20dollar%20amounts%20entered%20on%20Sheet%201%20that%20will%20be%20added%20and%20totaled%20on%20Sheet%204.%20I%20know%20that%20there%20are%20three%20wildcard%20symbols%20I%20can%20use.%20I'm%20thinking%20that%20I'll%20need%20more%20than%20one%20to%20get%20this%20done%20right.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1600583%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602261%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1602261%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F765340%22%20target%3D%22_blank%22%3E%40Bigtoes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Bigtoes%2C%3C%2FP%3E%3CP%3EI%20am%20not%20sure%20I%20understand%20fully.%20By%20%22Row%20A%22%20you%20meant%20row%201%2C%20correct%3F%20I%20am%20assuming%20you%20did.%3C%2FP%3E%3CP%3EFor%20sheet%201%2C%20you%20put%20the%20date%20in%20the%20A%20column%2C%20and%20based%20on%20the%20fact%20it%20has%20a%20date%2C%20when%20you%20press%20%22go%22%20you%20want%20it%20to%20take%20the%20amounts%20in%20different%20cells%20and%20add%20them%20to%20the%20cell%20in%20F%2C%20then%20transfer%20that%20to%20a%20cell%20on%20sheet%204.%20Correct%3F%20Are%20all%20the%20amounts%20to%20be%20added%20in%20the%20same%20row%3F%20After%20the%20macro%20would%20run%2C%20what%20happens%20to%20the%20date%20on%20sheet%201%3F%20If%20you%20run%20the%20macro%20again%2C%20where%20would%20the%20next%20total%20be%20placed%3F%20Below%20the%20last%20one%3F%20On%20sheet%201%2C%20is%20there%20a%20column%20that%20has%20unique%20entries%2C%20like%20a%20part%20number%20or%20a%20name%20that%20is%20used%20only%20once%3F%3C%2FP%3E%3CP%3EIf%20there%20is%20a%20unique%20identifier%20column%20on%20sheet%201%20you%20may%20be%20able%20to%20do%20this%20with%20formulas.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602457%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1602457%22%20slang%3D%22en-US%22%3EThe%20dates%2C%20as%20in%20the%20day%20number%20(1%2C2%2C3...)%2C%20are%20down%20column%20A%20from%20cell%202-32%20and%20A1is%20labeled%20Date.%20Along%20the%20top%20row%20(Row%201)%2C%20from%20B-M%20are%20the%20names%20of%20the%20months.%20That%20is%20all%20on%20Sheet%204.%20Column%20A%20on%20Sheet%201%20is%20for%20a%20formatted%20date%2C%20ie%3A%2001%2F01.%20The%20revenue%20from%20that%20date%20is%20recorded%20in%20Column%20F.%20The%20macro%20I%20need%20to%20create%20involves%20having%20the%20correct%20date%20and%20all%20of%20the%20dollar%20ampunts%20from%20a%20particular%20date.%20It%20would%20need%20to%20recognize%20a%20particular%20date%20for%20at.%20It%20would%20also%20need%20to%20add%20all%20of%20the%20dollar%20amounts%20from%20any%20day%20indicared%20by%20that%20format.%20The%20information%20would%20then%20be%20totaled%20and%20put%20in%20the%20proper%20cell%20on%20Sheet%204.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602507%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1602507%22%20slang%3D%22en-US%22%3EAre%20you%20able%20to%20provide%20a%20sample%20of%20the%20spreadsheet%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1603790%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1603790%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F765340%22%20target%3D%22_blank%22%3E%40Bigtoes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Bigtoes.%3C%2FP%3E%3CP%3EFirst%20thing%20I%20noticed%20was%20there%20is%20a%20%22space%22%20at%20the%20end%20of%20the%20word%20MAIN%20on%20the%20MAIN%20tab.%20I%20removed%20it%20from%20my%20copy.%20Spaces%20like%20that%20make%20formulas%20not%20work%20if%20they%20are%20not%20accounted%20for.%20On%20the%20Earnings%20tab%20I%20put%20a%20sumif%20equation%20in%20the%20first%20cell%20for%20you%20to%20show%20how%20it%20will%20add%20all%20of%20the%201%2F1%2F2020%20amounts%2C%20and%20all%20the%20other%20amounts%20are%20for%20examples.%20The%20formula%20will%20drag%20and%20drop.%20On%20the%20Earnings%20tab%2C%20row%2040%2C%20I%20added%20a%20year%20(a40)%20and%20the%20numbers%20represent%20the%20months.%20These%20are%20used%20to%20make%20the%20formulas%20work.%20You%20can%20hide%20this%20row.%20For%20February%2029%20I%20had%20to%20create%20a%20special%20formula%20that%20accounts%20for%20leap%20year%20so%20do%20not%20copy%20over%20that%20one.%20Let%20me%20know%20if%20this%20works.%3C%2FP%3E%3CP%3EThere%20are%20circular%20references%20in%20this%20spreadsheet%20so%20you%20will%20need%20to%20fix%20those.%20Ex.%20J35%20has%20a%20formula%20that%20sums%20itself.%20(%3Dsum(h35%3Aj35)).%20Others%20have%20this%20same%20error.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602802%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20Macros%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1602802%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F628423%22%20target%3D%22_blank%22%3E%40SqueakySneakers%3C%2FA%3EHere%20is%20a%20copy%20of%20the%20spreadsheet%20I'm%20working%20with.%20I%20have%20actual%20data%20that%20I%20need%20to%20assimilate.%20I%20just%20need%20to%20be%20pointed%20ion%20a%20direction%20that%20will%20allow%20me%20to%20transfer%20data%20between%20sheets%20as%20it's%20entered%2C%20instead%20of%20having%20to%20hit%20shortcut%20keys.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I'm trying to create a macro in Excel 2013 through Developer. I need to be able to have it take information from multiple cells on Sheet 1 for a date that is recorded in the A column with the months across the top on the A row. I need them to take information put in column F and add it together and put it in the proper cell on Sheet 4, where it can be shown as a total. I'm not sure how to write a macro that would be able to do that for multiple pieces of information that need to consolidated on different sheets in my workbook. Please help. I'm working with different dollar amounts entered on Sheet 1 that will be added and totaled on Sheet 4. I know that there are three wildcard symbols I can use. I'm thinking that I'll need more than one to get this done right.

6 Replies
Highlighted

@Bigtoes 

Hi Bigtoes,

I am not sure I understand fully. By "Row A" you meant row 1, correct? I am assuming you did.

For sheet 1, you put the date in the A column, and based on the fact it has a date, when you press "go" you want it to take the amounts in different cells and add them to the cell in F, then transfer that to a cell on sheet 4. Correct? Are all the amounts to be added in the same row? After the macro would run, what happens to the date on sheet 1? If you run the macro again, where would the next total be placed? Below the last one? On sheet 1, is there a column that has unique entries, like a part number or a name that is used only once?

If there is a unique identifier column on sheet 1 you may be able to do this with formulas.

Highlighted
The dates, as in the day number (1,2,3...), are down column A from cell 2-32 and A1is labeled Date. Along the top row (Row 1), from B-M are the names of the months. That is all on Sheet 4. Column A on Sheet 1 is for a formatted date, ie: 01/01. The revenue from that date is recorded in Column F. The macro I need to create involves having the correct date and all of the dollar ampunts from a particular date. It would need to recognize a particular date for at. It would also need to add all of the dollar amounts from any day indicared by that format. The information would then be totaled and put in the proper cell on Sheet 4.
Highlighted
Are you able to provide a sample of the spreadsheet?
Highlighted

@SqueakySneakersHere is a copy of the spreadsheet I'm working with. I have actual data that I need to assimilate. I just need to be pointed ion a direction that will allow me to transfer data between sheets as it's entered, instead of having to hit shortcut keys.

Highlighted

@Bigtoes 

Hi Bigtoes.

First thing I noticed was there is a "space" at the end of the word MAIN on the MAIN tab. I removed it from my copy. Spaces like that make formulas not work if they are not accounted for. On the Earnings tab I put a sumif equation in the first cell for you to show how it will add all of the 1/1/2020 amounts, and all the other amounts are for examples. The formula will drag and drop. On the Earnings tab, row 40, I added a year (a40) and the numbers represent the months. These are used to make the formulas work. You can hide this row. For February 29 I had to create a special formula that accounts for leap year so do not copy over that one. Let me know if this works.

There are circular references in this spreadsheet so you will need to fix those. Ex. J35 has a formula that sums itself. (=sum(h35:j35)). Others have this same error.

Highlighted
Also, if you change the year in cell A40, it will work for that year, but for only one year at a time.