我期待執行一個代碼,它將返回「E」或「F」的3個值並且也返回A,B,C或D的2個值。以下是我目前爲止的內容。循環代碼,返回E或F的3個值以及A,B,C或D的2個值
Sheets("123").Select
Dim rng As Range
Dim count As Integer
Set rng = Range("L2:L500000")
For Each cell In rng
If Left(cell.Value, 1) = "A" Or Left(cell.Value, 1) = "B" Or _
Left(cell.Value, 1) = "C" Or Left(cell.Value, 1) = "D" Or _
Left(cell.Value, 1) = "E" Or Left(cell.Value, 1) = "F" Then
cell.EntireRow.Interior.ColorIndex = 4
count = count + 1
End If
If count >= 5 Then Exit For
Next
這不是真的清楚你的要求。 – SJR
基本上,如果單元格範圍內有字母A,B,C,D,E或F,代碼將突出顯示5行。但是,我需要總共3行返回字母A,B,C或D和總共兩行字母E或F.該代碼也隨機對數據進行隨機排序(如預期),但會給我不同的組合第一組字母與第二組字母,即A行,B行,C行或D行以及E行或行行4行。 –
您能舉一個預期的輸入和輸出示例嗎? –