New to Macros

Royal Presence

Board Regular
Joined
Feb 27, 2003
Messages
92
New to Macros
Hello everyone,

The board has been very generous in offering tips and suggestions to me. Most recently, some formulas were supplied for me to assist in a project. I successfully applied such and then I thought I was brave enough for macros. I actually made a few and they worked, of course I have new questions.

1st- what is best practice- would it be writing the VBA or doing a macro? I really don't know much about either, so figure I will take some classes.

2nd- In the development and learning curve of my new macro, I found out that changes to the original data were made, after we ran our report. Based on production issues, we don't want this to happen. First action is to notify anyone involved to not add data after a certain cutoff. But, second action might be to figure out how to incorporate this perhaps at midday on this weekly run. The report is to be run on a weekly basis and serves as production capacity. If re-run mid day, I would see these changes, but if not, the data is there, but I don't see it, because I haven't looked. If I have to go the second route, how do I go about rerecording the macro, or is best to incorporate solid code that I should learn. This particular report will be essential and we test drove it today, finding the above issue of change.
3rd- I really don't want to increase file sizes incredibly, so think I may need to know the most efficient way to keep the data clean and running smoothly.
Any ideas to any of the above?
I put this post in the Macro book section by mistake, so hopefully I did not offend anyone by double posting.

Thank you.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
1st : A macro is recorded in VBA. Writing the code by yourself offers you the possibility of doing much more than if you just record a macro, just with the fact that you can use variables. Also, if you write it by yourself, the code will probably more optimized than with the record macro utility, just as an exemple :

Code:
Sub Macro3()
'
' Macro3 Macro
' Macro enregistrée le 2003-10-29 par MP
'

'
    Range("C12").Select
    ActiveCell.FormulaR1C1 = "Hello"
    Range("C12").Select
    Selection.Font.ColorIndex = 3
    Range("D13").Select
    ActiveCell.FormulaR1C1 = "=R[-1]C[-1]"
    Rows("13:13").Select
    Selection.Insert Shift:=xlDown
    Range("C13").Select
End Sub

You'll get the same result with this :

Sub Macro4()
    
    Range("C12").Value = "Hello"
    Range("C12").Font.ColorIndex = 3
    Range("D13").Formula = "=C12"
    Rows("13:13").Insert Shift:=xlDown
    
End Sub
But using the record function is really useful to learn how to write code in vba for Excel.

2nd: Don't really understand what you're saying

3rd: Using VBA module doesn't increase the file really much if it's basic. Adding a picture increase much more a file than adding a module of vba. Well, if you add a lot of Controls and Userforms instead of only modules, then the file may increase more. Anyways, if you want only to add macros recorded in Excel, then it only uses vba module (code), no userform/controls, so it won't be huge.

Hope this helps,
 
Upvote 0
Thanks! You are the only person to acquaint yourself with my question.

My second question is that I create a macro to run a report that is based on time. It is based on if run on a certain day, not really the time of day. What the Production Manager would like to see is just one set of data for certain products. As our product is custom made, the forecasting is a bit backwards. Anyway, the little button I made to get all the necessary data, only included running it at that point in time, not if things were updated from the main data sheet later in the day.

I so thank you for responding.

I was wondering if the simple macro would take up more space and do worry about data increasing the file size. When I put formulas into the main data sheet, the size crept incredibily. So, I thank you twice for answering this question too.
 
Upvote 0
Hi

To progress this further, suggest that you post some sample data (using Colo's HTML utility), together with expected results.

Regards

Alan
 
Upvote 0

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,093
Latest member
ripvw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top