View Single Post
 
Old 11-15-2022, 06:12 AM
Hanfrn Hanfrn is offline Windows 10 Office 2019
Novice
 
Join Date: May 2022
Posts: 2
Hanfrn is on a distinguished road
Default Daily Spreadsheet Macro

Hi guys,

I have a spreadsheet that I populate every day. I recorded a macro to help me out with some repetitive routines. The macro works, but it is also doing a few things I want to avoid.

In column C, all numbers not in bold should have a minus (-). When the cell is blank, the macro place an "0". I want to leave it empty. The next day when I populate the sheet again, the macro should work only in those cells I populate for that day.

The same happens in column D, I populate with a number, and I want the macro to add "MIT/" in front of the number. The cells with no number leave it blank. The next day, the macro should work only in those cells I populate for that day and not add another MIT/MIT/9874

My macro code is the following:

Macro for Column C

' Amount2 Macro
'
'
Range("C6").Select
ActiveCell.FormulaR1C1 = "-1"
Range("C6").Select
Selection.Copy
Range("C8,C10,C12,C14,C16,C18,C20,C22,C24,C26,C28, C30,C32,C34,C36,C38,C40,C42,C44,C46,C48,C50,C52,C5 4,C56,C58,C60,C62,C64,C66,C68,C70,C72,C74,C76,C78, C80,C82,C84,C86,C88,C90,C92,C94,C96,C98,C100").Sel ect
Range("C100").Activate
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Range("C6").Select
Application.CutCopyMode = False
Selection.ClearContents

Macro for Column D:

Sub AddMit()
'
' Add MIT/ to the Colunm D
'
'
Range("P8").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=""MIT/""&RC[-12]"
Range("P8").Select
Selection.AutoFill Destination:=Range("P8:P100"), Type:=xlFillDefault
Range("P8:P100").Select
ActiveWindow.SmallScroll Down:=-70
Selection.Copy
Range("D8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P8:P100").Select
Application.CutCopyMode = False
Selection.ClearContents

End Sub

Thanking you, guys, for any help.


Screenshot - Imgur: The magic of the Internet
Reply With Quote