KISS Excel VBA
Keep It Super Simple with Excel VBA
Module_02_Values_to_cells
Copy and paste the below into a module in VBA
Sub Text_to_cells()
'How to enter (hardcode) text into cells
ActiveCell.Value = "qwe"
'Cell(1, 1).Value = "qwe"
End Sub
'--------------------------------------------------------------------------
Sub Numbers_to_cells()
'How to enter Numbers into cells
ActiveCell.Value = "5"
'same result
ActiveCell.Value = 5
End Sub
'--------------------------------------------------------------------------
Sub Numbers_to_cells_VBACalc()
'The calculation is done in VBA and the result is transfered to the active cell
ActiveCell.Value = 5 + 2
End Sub
'--------------------------------------------------------------------------
Sub Formula_to_cells()
'The calculation is done in excel, VBA only enters the formula to the active cell
ActiveCell.Value = "=1+3"
End Sub
'--------------------------------------------------------------------------
Sub Counter_add_to_number()
'Acts like a counter, increasing by one the current value
ActiveCell.Value = ActiveCell.Value + 1
End Sub
'--------------------------------------------------------------------------
Sub Counter_subtract_from_number()
'Acts like a counter, decreasing by one the current value
ActiveCell.Value = ActiveCell.Value - 1
End Sub
'--------------------------------------------------------------------------
Sub Increase_1_month()
'Increase selected dates by 1 month
For Each cell In Selection
cell.Value = DateAdd("m", 1, cell.Value)
Next
End Sub
'--------------------------------------------------------------------------
Sub Decrease_1_month()
'Decrease selected dates by 1 month
For Each cell In Selection
cell.Value = DateAdd("m", -1, cell.Value)
Next
End Sub
'--------------------------------------------------------------------------
Sub Counts_how_many_cells_have_values()
'Counts how many cells have values in the active sheet
MsgBox Application.WorksheetFunction.CountA(ActiveSheet.Cells)
End Sub