"Alpha Roster"와 "Paid"두 개의 별도 시트에서 이름을 정리하려고합니다. 알파 로스터 (Alpha Roster)는 다른 사람들에 의해 업데이트되며 유료는 누가 돈을 지불했는지에 대한 마스터 트래커입니다. 나는 알파 로스터 (Alpha Roster)에 대한 수정 작업에 상당히 잘 작동하는 "MakeProper"라는 기능을 가지고 있지만 어떤 이유 때문에 유료로 수정하지는 않습니다. 두 시트가 동일하게 설정됩니다.vba 서브 루틴은 시트 하나에서 작동하지만 다른 시트에서는 작동하지 않습니다.
Sub CleanUpPaid()
Sheets("Paid").Activate
Sheets("Paid").Select
Range("A2").Select
MakeProper
End Sub
Sub MakeProper()
Dim rngSrc As Range
Dim lMax As Long, lCtr As Long
Set rngSrc = ActiveSheet.Range(ActiveWindow.Selection.Address)
lMax = rngSrc.Cells.Count
' clean up Sponsor's Names
For lCtr = 3 To lMax
If Not rngSrc.Cells(lCtr, 1).HasFormula And _
rngSrc.Cells(lCtr, 1) <> "CMC" Then
rngSrc.Cells(lCtr, 1) = MakeBetterProper(rngSrc.Cells(lCtr, 1))
End If
' clean up Guest's Names
If Not rngSrc.Cells(lCtr, 7).HasFormula Then
rngSrc.Cells(lCtr, 7) = MakeBetterProper(rngSrc.Cells(lCtr, 7))
End If
Next lCtr
'MsgBox ("Make Proper " & ActiveSheet.Name)
End Sub
Function MakeBetterProper(ByVal ref As Range) As String
Dim vaArray As Variant
Dim c As String
Dim i As Integer
Dim J As Integer
Dim vaLCase As Variant
Dim str As String
' Array contains terms that should be lower case
vaLCase = Array("CMC", "II", "II,", "III", "III,")
ref.Replace what:=",", Replacement:=", "
ref.Replace what:=", ", Replacement:=", "
ref.Replace what:="-", Replacement:=" - "
c = StrConv(ref, 3)
'split the words into an array
vaArray = Split(c, " ")
For i = (LBound(vaArray) + 1) To UBound(vaArray)
For J = LBound(vaLCase) To UBound(vaLCase)
' compare each word in the cell against the
' list of words to remain lowercase. If the
' Upper versions match then replace the
' cell word with the lowercase version.
If UCase(vaArray(i)) = UCase(vaLCase(J)) Then
vaArray(i) = vaLCase(J)
End If
Next J
Next i
' rebuild the sentence
str = ""
For i = LBound(vaArray) To UBound(vaArray)
str = str & " " & vaArray(i)
str = Replace(str, " - ", "-")
str = Replace(str, "J'q", "J'Q")
str = Replace(str, "Jr", "Jr.")
str = Replace(str, "Jr..", "Jr.")
str = Replace(str, "(Jr.)", "Jr.")
str = Replace(str, "Sr", "Sr.")
str = Replace(str, "Sr..", "Sr.")
Next i
MakeBetterProper = Trim(str)
End Function
선택과 활성화의 차이점에 대해 읽었습니다. 보시다시피, CleanUpPaid에서 나는 유료 시트를 활성 시트로 만드는 두 가지 방법을 시도하지만 Alpha Roster 에서처럼 시트에 아무 것도 나타나지 않습니다.
_answer_을 게시하여 _question_를 업데이트하지 마십시오. 마지막으로 게시 한 것을 게시하려면 답변을 게시하십시오. –