0% found this document useful (0 votes)
74 views2 pages

Excel Formula

This document contains code snippets for various VBA macros and functions. It includes a macro to delete empty columns from a selected range, an IF statement formula to check for text patterns and return dates, macros to copy and paste entire rows or columns, and a user-defined function to sum every nth row or column in a range.

Uploaded by

jian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views2 pages

Excel Formula

This document contains code snippets for various VBA macros and functions. It includes a macro to delete empty columns from a selected range, an IF statement formula to check for text patterns and return dates, macros to copy and paste entire rows or columns, and a user-defined function to sum every nth row or column in a range.

Uploaded by

jian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

=MOD(COLUMN(),5)=3 , 3 IS WHICH COLUMN START

Sub DeleteEmptyColumns()
'Updateby20140317
Dim rng As Range
Dim InputRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = InputRng.Columns.Count To 1 Step -1
Set rng = InputRng.Cells(1, i).EntireColumn
If Application.WorksheetFunction.CountA(rng) = 0 Then
rng.Delete
End If
Next
Application.ScreenUpdating = True
End Sub

IF THE TEXT CONTAIN. THEN, OR ELSE


=IF(OR(
ISNUMBER(SEARCH("3+3",O2)),
ISNUMBER(SEARCH("3+3+3",O2)),
ISNUMBER(SEARCH("3+3+3+3",O2)),
ISNUMBER(SEARCH("3+3+3+3+3",O2))),
EDATE(I2,36)-1,
IF(OR(
ISNUMBER(SEARCH("2+2",O2)),
ISNUMBER(SEARCH("2+2+2",O2)),
ISNUMBER(SEARCH("2+2+2+2",O2)),
ISNUMBER(SEARCH("2+2+2+2+2",O2))),
EDATE(I2,24)-1,"-"))

COPY ENTIRE ROW FORMULA


Sub Paste_OneRow()

'Copy and Paste Row


Range("20:20").Copy Range("21:1000")

End Sub

COPY ENTIRE COLUMN FORMULA


Sub PasteOneColumn()

'Copy and Paste Column


Range("d:h").Copy Range("i:ix")
Application.CutCopyMode = False

End Sub

SAVE this formula in VBA only, then can use =SumIntervalCols(F3:DPO3,5)


Function SumIntervalRows(WorkRng As Range, interval As Integer) As Double
'Update 20130907
Dim arr As Variant
Dim total As Double
total = 0
arr = WorkRng.Value
For i = interval To UBound(arr, 1) Step interval
total = total + arr(i, 1)
Next
SumIntervalRows = total
End Function
Function SumIntervalCols(WorkRng As Range, interval As Integer) As Double
Dim arr As Variant
Dim total As Double
total = 0
arr = WorkRng.Value
For j = interval To UBound(arr, 2) Step interval
total = total + arr(1, j)
Next
SumIntervalCols = total
End Function

You might also like