Hello everyone
I have a worksheet that has multiple columns, e.g.:
a b c d e
1 2 3 4 5
6 7 8 9 0
What I need to do is 'find' columns B and D and create a new column:
a b c d e f
1 2 3 4 5 =2/4
6 7 8 9 0 =7/9
I am trying to use this macro to find each column (one is called MtM/D):
[Problem: XlDown stops when there is a gap in the column]
And this one to divide the two ranges, which creates a new column after the last (MTM Date):
I am stuck with the range selection and how to divide the two ranges. Can anyone help please!?
Thank you!!
I have a worksheet that has multiple columns, e.g.:
a b c d e
1 2 3 4 5
6 7 8 9 0
What I need to do is 'find' columns B and D and create a new column:
a b c d e f
1 2 3 4 5 =2/4
6 7 8 9 0 =7/9
I am trying to use this macro to find each column (one is called MtM/D):
Code:
Dim rngAddress As Range
Set rngAddress = Range("A3:Z3").Find("MtM/D")
If rngAddress Is Nothing Then
MsgBox "MtM/D column was not found."
Exit Sub
End If
Range(rngAddress, rngAddress.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="MtMD", RefersTo:=Selection
[Problem: XlDown stops when there is a gap in the column]
And this one to divide the two ranges, which creates a new column after the last (MTM Date):
Code:
Dim Found As Range
Dim LR As Long
Set Found = Rows(3).Find(what:="MtM Date", LookIn:=xlValues, lookat:=xlWhole)
If Found Is Nothing Then Exit Sub
LR = Cells(Rows.Count, Found.Column).End(xlUp).Row
Found.Offset(, 1).EntireColumn.Insert
Cells(3, Found.Column + 1).Value = "Percentage"
Range(Cells(4, Found.Column + 1), Cells(LR, Found.Column + 1)).Formula = "<named ranges>"
End Sub
I am stuck with the range selection and how to divide the two ranges. Can anyone help please!?
Thank you!!