Combine two macros into one

Timxyz

New member
Joined
Sep 4, 2013
Messages
3
Reaction score
0
Points
0
Is it possible to combine these into one Macro

The 1st sub acts on columns by a array of header names


I have to run the 2nd sub on numerous non-contiguous columns so I am calling it up the 10 different times.


I would like to combine the first sub with the second so as to run the 2nd sub by a list of header names.


I have tried combing them but have had no success, can't get how to use the"colToFormat" of the 1st sub in the 2nd sub.


Thanks

Code:
[COLOR=#333333]
[/COLOR]Sub fmt()
    ColList = "Field1,Field2,Field3,Field4"
    colarray = Split(ColList, ",")
    Set colToFormat = Nothing
    For Each heading In colarray
    Set headingFound = Range("A:A").Offset(0, ActiveSheet.Cells.Find(What:=heading, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Column - 2)


      If colToFormat Is Nothing Then Set colToFormat = headingFound Else Set colToFormat = Union(colToFormat, headingFound)
    Next
    MsgBox colToFormat.Address


End Sub

Code:
Sub FillColBlanks(sColRange As String)


'by Dave Peterson  2004-01-06
'fill blank cells in column with value above
Dim wks As Worksheet
Dim rng As Range
Dim Lastrow As Long
Dim col As Long




Set wks = ActiveSheet
With wks
 
   col = .Range(sColRange As String).Column


   Set rng = .UsedRange  'try to reset the lastcell
   Lastrow = .Cells.SpecialCells(xlCellTypeLastCell).Row
   Set rng = Nothing
   On Error Resume Next
   Set rng = .Range(.Cells(2, col), .Cells(Lastrow, col)) _
                  .Cells.SpecialCells(xlCellTypeBlanks)
   On Error GoTo 0


   If rng Is Nothing Then
       MsgBox "No blanks found"
       Exit Sub
   Else
       rng.FormulaR1C1 = "=R[-1]C"
   End If


   'replace formulas with values
   With .Cells(1, col).EntireColumn
       .Value = .Value
   End With


End With
End Sub
 
Back
Top