Public Sub DataRanges()
'Sets the data ranges for the data sources, copies the account number into
'associated column
Dim rngchar As Range, rngCharAcct As Range, rngTop10 As Range, rngTop10Acct As Range
Dim rnggics As Range, rnggicsAcct As Range, rngCountry As Range, rngCountryAcct As Range
Dim rngSecurities As Range, rngCheck As Range, wks As Worksheet
Dim strAccount As String
For Each wks In Worksheets
If wks.Name Like "MySheet_*" Then
wks.Activate
strAccount = CStr(Left(wks.Range("A2").Value, 6))
Set rngchar = wks.Range("C11:G15")
Set rngCharAcct = wks.Range("H11:H15")
Set rngTop10 = wks.Range("C35:F44")
Set rngTop10Acct = wks.Range("H356:H44")
Set rnggics = wks.Range("A68:D77")
Set rnggicsAcct = wks.Range("H68:H77")
Set rngSecurities = wks.Range("C16:E16")
Set rngCheck = Cells(Rows.Count, "E").End(xlUp).Offset(-1, -1)
If rngCheck.Value <= 5 Then
Set rngCountry = Range(Cells(98, "A"), Cells(Rows.Count, "E").End(xlUp).Offset(-2, 0))
Set rngCountryAcct = Range(Cells(98, "H"), Cells(Rows.Count, "E").End(xlUp).Offset(-2, 3))
Else
Set rngCountry = Range(Cells(98, "A"), Cells(Rows.Count, "E").End(xlUp).Offset(-1, 0))
Set rngCountryAcct = Range(Cells(98, "H"), Cells(Rows.Count, "E").End(xlUp).Offset(-1, 3))
End If
'Copy account number to selection ranges in column H
'ERRORS OUT HERE!
wks.Range(rngCharAcct).Select
ActiveSheet.Paste (strAccount)
wks.Range(rngTop10Acct).Select
ActiveSheet.Paste (strAccount)
wks.Range(rnggicsAcct).Select
ActiveSheet.Paste (strAccount)
wks.Range(rngCountryAcct).Select
ActiveSheet.Paste (strAccount)
End If
Next
End Sub
|