Forum Discussion
JMKnox
Jan 18, 2023Copper Contributor
How to apply changes only to active rows when writing a macro
I am trying to write a macro which will insert a few blank columns and then insert specific values into the new columns (one example is simply inserting the letter "C"). This is easy to do manually, ...
HansVogelaar
Jan 18, 2023MVP
For example:
Sub Test()
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("D1:F1").EntireColumn.Insert
Range("D1:F" & LastRow).Value = "C"
Application.ScreenUpdating = True
End SubShiming
Jan 30, 2023Copper Contributor
Hi Hans, sorry it might sound idiot but can you tell me what subject I should learn in order to write these languages? Thanks.
- HansVogelaarJan 30, 2023MVP
It's called Visual Basic for Applications, abbreviation VBA.
See for example this Excel VBA Tutorial