![]() |
|
#1
|
||||
|
||||
![]()
Try the following macro. Depending on which sheet holds the data, you may need to change 'Sheet1' to the correct sheet name.
Code:
Sub Test() Dim StrB As String, x As Long, LastRow As Long, i As Long With ActiveWorkbook.Sheets("Sheet1") LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row For x = 1 To LastRow If .Cells(x, 1).Value <> "" Then StrB = .Cells(x, 2).Value .Cells(x, 3).Value = ((Len(StrB) - Len(Replace(StrB, "1w", ""))) * 1 + (Len(StrB) - Len(Replace(StrB, "2w", ""))) * 2 + _ (Len(StrB) - Len(Replace(StrB, "3w", ""))) * 3 + (Len(StrB) - Len(Replace(StrB, "4w", ""))) * 4 + _ (Len(StrB) - Len(Replace(StrB, "5w", ""))) * 5 + (Len(StrB) - Len(Replace(StrB, "6w", ""))) * 6 + _ (Len(StrB) - Len(Replace(StrB, "7w", ""))) * 7 + (Len(StrB) - Len(Replace(StrB, "8w", ""))) * 8) / 2 End If Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jamal NUMAN | Excel | 12 | 07-09-2018 11:44 PM |
![]() |
tomlam | Excel | 5 | 10-07-2012 06:09 AM |
Is it possible to write down a number starting with zero in excel cell? | Rahmat_uk20 | Excel | 3 | 06-08-2012 02:26 AM |
![]() |
tpcervelo | Excel Programming | 1 | 01-05-2012 10:14 PM |
![]() |
zanat0s | Excel | 3 | 06-09-2011 10:53 AM |