Sub clearcell() 'note no column heading. data starts from A1. Modify if necessary Worksheets("sheet1").Activate Set r = Range(Range("A1"), Range("A1").End(xlDown)) For Each c In r If Trim(c) <> "arg1" And Trim(c) <> "arg2" Then c.Clear Next c End Sub
Sub replcenumber() Worksheets("sheet2").Activate Set r = Range(Range("B2"), Cells(Rows.Count, "A").End(xlUp).Offset(0, 1)) For Each c In r If c <> "" Then c = Trim(c) j = Len(c) 'MsgBox j For k = 1 To j If IsNumeric(Mid(c, k, 1)) Then m = m & Mid(c, k, 1) Next k MsgBox m c.Offset(0, -1) = m End If m = "" Next c End Sub
Sub replaceNumber() Set r = Range(Range("Q4"), Cells(Rows.Count, "T").End(xlUp).Offset(0, 1)) For Each c In r If c <> "" Then c = Trim(c) j = Len(c) 'MsgBox j For k = 1 To j If IsNumeric(Mid(c, k, 1)) Then m = m & Mid(c, k, 1) Next k MsgBox m c.Offset(0, -1) = m End If m = "" Next c End Sub
oris blank, replace/fill in the value of column T into column Q.
Sub clearcell() Dim r As Range, c As Range 'note no column heading. data starts from A1. Modify if necessary Worksheets("sheet1").Activate Set r = Range(Range("A1"), Range("A1").End(xlDown)) For Each c In r If Trim(c) <> "arg1" And Trim(c) <> "arg2" Then c.EntireRow.Delete Next c End Sub
DON'T MISS