I’ve been able to make macro’s to do one or the other but have struggled to combine them. I need it to be able to check if the first three characters are a match and check if the cell has strikethrough before counting.
Sub check_strikethrough()
Dim x ,i As Long
Dim cellcount As Long
x = WorksheetFunction.CountIf(Columns(1), "aaa*") 'count how many "aaa" instances (1st three chars match)
'replace "aaa" with your three letter text as required. Wildcard neded
cellcount = 0
For i = 1 To x
Columns(1).Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If ActiveCell.Characters.Font.Strikethrough = True Then
cellcount = cellcount + 1
End If
Next i
End Sub
Sub check_strikethrough()
Dim x, result As Long
Dim cellcount As Long
x = WorksheetFunction.CountIf(Columns(1), "bbb*") 'count how many "aaa" instances (1st three chars match)
'replace "aaa" with your three letter text as required. Wildcard neded
cellcount = 0
For i = 1 To x
Columns(1).Find(What:="bbb", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If ActiveCell.Characters.Font.Strikethrough = True Then
cellcount = cellcount + 1
End If
Next i
result = x - cellcount
End Sub
Thank you so much for your help. Pardon my stupidity but this is my first time dealing with vba and excel so how would I run this? I also should have specified I need it to output the value into a cell as wellapologies - I just saw your heading and realised I had the result the wrong way around.
new code below.
VBA Code:Sub check_strikethrough() Dim x, result As Long Dim cellcount As Long x = WorksheetFunction.CountIf(Columns(1), "bbb*") 'count how many "aaa" instances (1st three chars match) 'replace "aaa" with your three letter text as required. Wildcard neded cellcount = 0 For i = 1 To x Columns(1).Find(What:="bbb", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate If ActiveCell.Characters.Font.Strikethrough = True Then cellcount = cellcount + 1 End If Next i result = x - cellcount End Sub
I should’ve worded that I’ve been able to make them work through copy and paste parts from other peoples macros. I’m familiar with python but not vba or excel so I have a very small understanding of what I’m reading in others vba code."I’ve been able to make macro’s to do one or the other"
and
"first time dealing with vba and excel so how would I run this?"
Don't back each other up.
Re: "check if the first three characters are a match"
A match to what? Each other?
Are all the cells to start with these 3 characters or a user supplied string of 3 characters?
Re: "I need it to output the value into a cell as well"
Same row to the right? To the left? 6 Cells to the Right? Under one another in a Column? If so, which Column?
You do have a header in your first row, do you?
We have more questions than you!!!!!!
So this is the spreadsheet I’m trying to improve. We deal with filing flight plans for aircraft. So what I want to do is to be able to do is count the aircraft type in column e for each day while excluding canceled flight plans that we notate with a strikethrough. I would like the output value in a cell that I would be able to reference to in a function in a different spreadsheetRe: "set the output cell as you would with other excel functions"
What does that mean?
Is it OK to get the 3 characters with an InputBox? Or, like you mentioned, from a cell? However, you do not mention which cell. Cell X235 maybe?
So this is the spreadsheet I’m trying to improve. We deal with filing flight plans for aircraft. So what I want to do is to be able to do is count the aircraft type in column e for each day while excluding canceled flight plans that we notate with a strikethrough. I would like the output value in a cell that I would be able to reference to in a function in a different spreadsheet
1-Mar | |||||||||
I/V | T | CALLSIGN | ACFT | ETD | ATD | ETE | ETA | ATA | |
2-Mar | |||||||||
I/V | T | CALLSIGN | ACFT | ETD | ATD | ETE | ETA | ATA | |
3-Mar | |||||||||
I/V | T | CALLSIGN | ACFT | ETD | ATD | ETE | ETA | ATA | |
4-Mar | |||||||||
I/V | T | CALLSIGN | ACFT | ETD | ATD | ETE | ETA | ATA | |
5-Mar |