Prasad Vithanala
New Member
- Joined
- Dec 14, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hi I want to use dynamic range for the following vba code. The below code says. only particular row number. but I need code according to the data available in the cells. My code is working fine with below. But I need generic code with without range. Am writing code for EoMonth function
Sub EoMonth()
Sheets("RPI").Select
Range("B1").EntireColumn.Insert
Dim Cell As Range
For Each Cell In Range("A2:A434")
Cell.Offset(0, 1) = Application.WorksheetFunction.EoMonth(Cell, -1)
Next Cell
Range("B2:B434").Font.Color = vbRed
Range("B2:B434").Interior.ColorIndex = 6
Sheets("CGT").Select
Range("B1").EntireColumn.Insert
For Each Cell In Range("A2:A102")
Cell.Offset(0, 1) = Application.WorksheetFunction.EoMonth(Cell, -1)
Next Cell
Range("B2:B102").Font.Color = vbRed
Range("B2:B102").Interior.ColorIndex = 6
End Sub
Sub EoMonth()
Sheets("RPI").Select
Range("B1").EntireColumn.Insert
Dim Cell As Range
For Each Cell In Range("A2:A434")
Cell.Offset(0, 1) = Application.WorksheetFunction.EoMonth(Cell, -1)
Next Cell
Range("B2:B434").Font.Color = vbRed
Range("B2:B434").Interior.ColorIndex = 6
Sheets("CGT").Select
Range("B1").EntireColumn.Insert
For Each Cell In Range("A2:A102")
Cell.Offset(0, 1) = Application.WorksheetFunction.EoMonth(Cell, -1)
Next Cell
Range("B2:B102").Font.Color = vbRed
Range("B2:B102").Interior.ColorIndex = 6
End Sub