I currently have a master excel sheet that has the names of about 20 different sales people, and a new row is created, with the salesmen name in column A, whenever they make a sale. But, I now want this data to be available to the salesmen, but I want only them to only be able to view their info, not everyones. So, I am going to create 20 different individual files, one for each salesman.
Is there a formula that I can use for these 20 different spreadsheets to update for that specific salesmen every time I update the master sheet?
You could create workbooks from a Column (Looping from row 1 to x) based on unique values.
So for each unique salesmen in Column A you create a new workbook. Then you only need to use your current Master file, and do whatever you want in that file. When you want to send a sheet to a sales person, you execute the code and Excel will copy all rows that belongs to the specific sales man and create 20 individual sheets for you which you can send.
Process:
I have a file in a folder, which I have all my main data.
The main data looks like this, and the new workbooks will be named after Column A. It will only create workbook for unique names.
After running the macro it has create the following 5 new workbooks.
This is how Workbook "Anne - 10-27-18,14.24.47.xlsx" looks like:
This is how Workbook "Belle- 10-27-18,14.24.47.xlsx" looks like:
I used the following code and only modified to make it dynamic of the unique list column. All credit to J. Fox at SO
VBA Code:
Option Explicit
Sub ExportByName()
'Source and Credit: https://stackoverflow.com/questions/46368771/how-to-create-a-new-workbook-for-each-unique-value-in-a-column
Dim unique(1000) As String 'How many unique values we can store
Dim wb(1000) As Workbook
Dim ws As Worksheet
Dim x As Long, y As Long, ct As Long, uCol As Long, ColName As Long
Dim StaticDate As Date
On Error GoTo ErrHandler
Application.ScreenUpdating = True
Application.Calculation = xlCalculationManual
'Your main worksheet
Set ws = ActiveWorkbook.Sheets("Sheet1")
'Column Where Unique Names are
ColName = 1
uCol = 12 'End column of data in MainFile
ct = 0
'get a unique list of users
For x = 2 To ws.Cells(ws.Rows.Count, ColName).End(xlUp).Row
If CountIfArray(ActiveSheet.Cells(x, ColName), unique()) = 0 Then
unique(ct) = ActiveSheet.Cells(x, ColName).Text
ct = ct + 1
End If
Next x
StaticDate = Now() 'This create the same timestamp for all the new workbooks
'loop through the unique list
For x = 0 To ws.Cells(ws.Rows.Count, ColName).End(xlUp).Row - 1
If unique(x) <> "" Then
'add workbook
Set wb(x) = Workbooks.Add
'copy header row
ws.Range(ws.Cells(1, 1), ws.Cells(1, uCol)).Copy wb(x).Sheets(1).Cells(1, 1)
'loop to find matching items in ws and copy over
For y = 2 To ws.Cells(ws.Rows.Count, ColName).End(xlUp).Row
If ws.Cells(y, ColName) = unique(x) Then
'copy full formula over
'ws.Range(ws.Cells(y, 1), ws.Cells(y, uCol)).Copy wb(x).Sheets(1).Cells(WorksheetFunction.CountA(wb(x).Sheets(1).Columns(uCol)) + 1, 1)
'to copy and paste values
ws.Range(ws.Cells(y, 1), ws.Cells(y, uCol)).Copy
wb(x).Sheets(1).Cells(WorksheetFunction.CountA(wb(x).Sheets(1).Columns(uCol)) + 1, 1).PasteSpecial (xlPasteValues)
End If
Next y
'autofit
wb(x).Sheets(1).Columns.AutoFit
'save when done
wb(x).SaveAs ThisWorkbook.Path & "\" & unique(x) & " - " & Format(StaticDate, "mm-dd-yy, hh.mm.ss") & ".xlsx"
wb(x).Close SaveChanges:=True
Else
'once reaching blank parts of the array, quit loop
Exit For
End If
Next x
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
ErrHandler:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Public Function CountIfArray(lookup_value As String, lookup_array As Variant)
CountIfArray = Application.Count(Application.Match(lookup_value, lookup_array, 0))
End Function
Related
Details: I have a worksheet that keeps track of jobs (Sheet 1). This is running on a macro that extracts data from another worksheet (Sheet 2). Sheet 2 contains data for all the possible workstations, and I have separate tabs in the workbook that are copies of Sheet 1, but for each individual workstation.
Currently, I have the macro successfully set up to add lines to Sheet 1 if it exists on Sheet 2 but not Sheet 1. That code is shown below. I do this by first filtering the data on Sheet 2 per column F (workstation name), then checking against Sheet 1's list of job names per column I against Sheet 2's job names in column K. If the job name already exists on Sheet 1, it is deleted off of Sheet 2. After all the existing ones are deleted, it then copies the remaining lines on Sheet 2 over to the first available blank spaces in Sheet 1. Sheet 2 then deletes itself.
Extra info to help:
Sheet 2 is copying from columns G to X
Sheet 1 is pasting from columns E to V
Edit note: I will clear out the .select lines in the final code.
Goal: It has been requested that even if the job already exists on Sheet 1, to copy the line over anyway because some of the other information may have been updated on Sheet 2. I have been unable to find the series of commands necessary to add to the existing code that will allow it to copy the row of information based on if it exists without changing its order on Sheet 1.
What I mean by this: It would be simple to just delete all of Sheet 1 and copy all rows over from Sheet 2. The row order on Sheet 1 is crucial to be kept as is, so each line on Sheet 2 needs to be checked one at a time to update Sheet 1's line in its current position. If it doesn't exist, then it still needs to add the full row over to Sheet 1 at the first open space.
I have had some luck with filtering Sheet 1 as well and referencing a cell for a match, but it would only work on the first row, and the code was very long and repetitive so I didn't want to go with it.
2/3/22 Edit: Got the code to work as intended, though it isn't the cleanest execution.
Sub Macro1()
ActiveSheet.Unprotect
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open Application.GetOpenFilename 'Click on Exported File with updates
Range("F3").Select
Selection.AutoFilter
With ActiveSheet
LastRow = .Cells(.Rows.Count, 10).End(xlUp).Row
.Range("A4:Z" & LastRow).AutoFilter Field:=6, Criteria1:="Workstation Name" 'change per workstation tab
End With
ActiveSheet.Move Before:=Workbooks("Book1.xlsm").Sheets(1)
Dim lr As Long
Dim chklr As Long
Dim rngtochk As Range
Dim i As Long
Dim fromws As Worksheet
Dim chktows As Worksheet
Dim iLastRow As Integer
Set fromws = Sheets("Sheet2")
Set chktows = Sheets("Workstation Tab")
lr = fromws.Cells(Rows.Count, "K").End(xlUp).Row
iLastRow = fromws.Range("G4").Top
For i = lr To 2 Step -1 'Loop start
lr = fromws.Cells(Rows.Count, "K").End(xlUp).Row
iLastRow = fromws.Range("G4").Top
fromws.Activate
Range("G4:X" & lr).SpecialCells(xlCellTypeVisible).Select
Range("G" & Selection.Row & ":X" & Selection.Row).Copy
chktows.Activate
Columns("AF:AH").ColumnWidth = 1 'Column manipulation required for some reason
Columns("AJ:AN").ColumnWidth = 1
Columns("AP:AQ").ColumnWidth = 1
chktows.Range("AC2").PasteSpecial xlPasteValues
chktows.Range("E4").AutoFilter
If chktows.Range("AC2") = "Column Header" Then 'Loop exit command
chktows.Range("AC2:AU2").ClearContents
Sheets("Sheet2").Delete
Columns("AF:AH").ColumnWidth = 0
Columns("AJ:AN").ColumnWidth = 0
Columns("AP:AQ").ColumnWidth = 0
chktows.AutoFilterMode = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End If
With chktows 'Continue loop
.Range("B3:S" & LastRow).AutoFilter Field:=4, Criteria1:=chktows.Range("AC2")
End With
currcell = Cells(i, 11).Value
chklr = chktows.Cells(Rows.Count, "I").End(xlUp).Row
Set rngtochk = chktows.Range("I4:I" & chklr)
Set Rng = chktows.Range("E4:E55").SpecialCells(xlCellTypeVisible)
If Rng = "" Then 'Check if line update or new line add at bottom
chktows.Range("E4").AutoFilter
chktows.Range("AC2:AU2").Copy
LastRow = chktows.Cells(Rows.Count, "E").End(xlUp).Row
chktows.Range("E" & LastRow).Offset(1, 0).Select
ActiveSheet.Paste
chktows.Range("AC2:AU2").ClearContents
fromws.Activate
Range("G4:X" & lr).SpecialCells(xlCellTypeVisible).Select
Range("G" & Selection.Row & ":X" & Selection.Row).Delete
Else
chktows.Activate
LastRow = chktows.Cells(Rows.Count, "E").End(xlUp).Row
Range("AC2:AU2").Copy
Range("E4:E54").SpecialCells(xlCellTypeVisible).Select
ActiveSheet.Paste
Range("E4").AutoFilter
Range("AC2:AU2").ClearContents
fromws.Activate
Range("G4:X" & lr).SpecialCells(xlCellTypeVisible).Select
Range("G" & Selection.Row & ":X" & Selection.Row).Delete
End If
Next
Sheets("Sheet2").Delete
Columns("AF:AH").ColumnWidth = 0
Columns("AJ:AN").ColumnWidth = 0
Columns("AP:AQ").ColumnWidth = 0
chktows.AutoFilterMode = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I'm trying to copy data from one sheet that contains raw data (over 30 columns and 300000 rows) into other sheets that split them into organized form.
In the DATA sheet I have repetitive ID's in column A, case numbers in column B which are unique and dates of cases in column J (multiple case numbers have the same date).
My goal is to copy case numbers into worksheets that are named with ID's from col A. In the target sheet I have single dates in col A (ex. from 3/01/2021 in A1 to 3/31/2021 in A31). The case numbers need to be transposed so they appear in columns next to each other but they have the same date.
I cannot use the ID's names in the code because it varies every month so I suppose that the code needs to work as some sort of comparison tool.
This should be close: it will add the sheets if they don't already exist.
Sub Copy_to_ID_sheet()
Dim impdate As Date, startDate As Date, daysToFillDown As Long
Dim finalrow As Long
Dim i As Long, numSheets As Long
Dim shipment As String, m
Dim ID As String, wsDane As Worksheet, dict As Object, ws As Worksheet
startDate = DateSerial(2021, 3, 1) 'adjust as needed
daysToFillDown = 31 '...and here
Set wsDane = ThisWorkbook.Sheets("Dane")
numSheets = ThisWorkbook.Worksheets.Count
Set dict = CreateObject("scripting.dictionary")
For i = 2 To wsDane.Cells(Rows.Count, "A").End(xlUp).Row
impdate = wsDane.Cells(i, 10).Value
shipment = wsDane.Cells(i, 2).Value
ID = Sheets("Dane").Cells(i, 1).Value
'already seen this ID and have a matching sheet?
If Not dict.exists(ID) Then
Set ws = Nothing
On Error Resume Next
Set ws = ThisWorkbook.Sheets(ID) 'does the sheet already exist?
On Error GoTo 0
If ws Is Nothing Then
'no existing sheet, so add a new one
Set ws = ThisWorkbook.Worksheets.Add( _
after:=ThisWorkbook.Worksheets(numSheets))
numSheets = numSheets + 1
ws.Name = ID
'add dates to the new sheet
With ws.Range("A1")
.NumberFormat = "mm/dd/yyyy" 'or whatever
.Value = startDate
.AutoFill Destination:=.Resize(daysToFillDown, 1)
End With
End If
Set dict(ID) = ws 'save in dictionary
Else
Set ws = dict(ID) 'get the existing sheet
End If
'match the date to the destination sheet
m = Application.Match(CLng(impdate), ws.Range("A1:A40"), 0)
If Not IsError(m) Then
'got a date match - add the shipment to the next available slot
ws.Cells(m, Columns.Count).End(xlToLeft).Offset(0, 1).Value = shipment
End If
Next i
End Sub
I have an excel workbook that have a subset of sheets with similar names: Data(US), Data(UK), Data(FR), Data(ES), etc... (in brackets there is the ISO code of the country which data refer to).
I would like to extract two data-points from all these sheets, and print them as a list in a new sheet to create a report.
Each sheet has the same structure inside (see here an image:
so that all the data-points are identified by coordinates for rows ("001","002", ... in row 6) and columns ("001", "002" in column D).
I am trying to write a code that does the following:
Open all sheets that have the name like: Data(**)
Inside the sheet, do a VLOOKUP to get the value corresponding to rows "001" and "002"
Print the data-points extracted in a new sheet, one after the other as a list in column D
Here is the code I wrote so far, which works only for the first sheet (Data(US)) and I included my questions as comments:
Sub ImportDataPoints()
Dim W As Worksheet, C&, F$
Dim D As String
'Take the folder path from cell D1
D = Worksheets("Input").Range("D1").Value
On Error Resume Next
'Target sheet to paste the data
Set W = ThisWorkbook.Worksheets("Data")
C = 3
Application.ScreenUpdating = False
'Open all workbooks in the folder that contain the following
F = Dir(D & "*FINANCIALDATA*" & "*.xlsx")
Do Until F = ""
C = C + 1
'Open the worksheet "Data(US)"
'### QUESTION: How to open all worksheets with similar names like Data(**)? ###
With Workbooks.Open(D & F).Worksheets("Data(US)")
'First datapoint to extract. Initial position: cell AA10.
'Do a VLOOKUP to search the value corresponding to coordinate "001"
.Range("AA10").FormulaR1C1 = "=VLOOKUP(""001"",C[-23]:C[-1],2,FALSE)"
'Move to AB10: if the previous value is empty, then give me zero
.Range("AB10").FormulaR1C1 = "=IF(RC[-1]="""",0,RC[-1])"
'Copy the value
.Range("AB10").Copy
'Paste the value in the Target sheet at row 10, column D
W.Cells(10, C).PasteSpecial xlPasteValues
'Do the same for the second datapoint and paste it in the Target sheet at row 11, column D
.Range("AA10").Offset(1, 0).FormulaR1C1 = "=VLOOKUP(""002"",C[-23]:C[-1],2,FALSE)"
.Range("AB10").Offset(1, 0).FormulaR1C1 = "=IF(RC[-1]="""",0,RC[-1])"
.Range("AB10").Offset(1, 0).Copy
W.Cells(11, C).PasteSpecial xlPasteValues
'### QUESTION: The macro should continue opening all the other sheets (Data(UK), Data(FR), Data(ES), etc...),
'### copying the datapoints 001-002 and pasting them in the same target sheet (column D, continuing from the row 11 onwards...)###
.Parent.Close False
End With
F = Dir
Loop
Set W = Nothing
Application.ScreenUpdating = True
End Sub
Does anybody know how to fix the code? Or if you can think to any other more efficient solution, all proposal are well accepted!
Many thanks in advance!
Something like this:
Sub ImportDataPoints()
Dim W As Worksheet, C&, F$
Dim D As String, wb As Workbook, targetRow As Long, sht As Worksheet
'Take the folder path from cell D1
D = Worksheets("Input").Range("D1").Value
'Target sheet to paste the data
Set W = ThisWorkbook.Worksheets("Data")
C = 3
Application.ScreenUpdating = False
'Open all workbooks in the folder that contain the following
F = Dir(D & "*FINANCIALDATA*.xlsx")
Do Until F = ""
C = C + 1
Set wb = Workbooks.Open(D & F)
targetRow = 10 'summary start row
For each sht in wb.worksheets
If sht.Name Like "Data(*)" Then
'....
'run your code for sheet sht
'....
targetRow = targetRow + 2 'next summary row
End With
Next sht
wb.close True
F = Dir
Loop
Set W = Nothing
Application.ScreenUpdating = True
End Sub
I am new to VB, and need some help. I have an excel 2013 workbook that has 2 sheets. Sheet1 is list of employee names (column A has 20 names), dob (column B), etc, and Sheet2 is a blank evaluation form. I need a code that will copy the entire Sheet2 (the blank form) and paste into a new Sheet3, and also pull the EmpName from row1 to a specified cell on Sheet3 (D4), same with DOB (J4), etc. I need it to repeat this process for every name on Sheet1. End goal is to have a workbook that contains 20 sheets, one for each employee, in the form of an evaluation. It would also be terrific if this code could name the tab the employee name. Is this possible? I've searched online extensively, and cannot find anything fitting.
Here is my current code. Like I said, I'm a VBA newbie. The code creates new sheets from the employee list, and copies data, but now I need it to also copy the entire sheet2 (eval form), and place the data (name cell A1 from employee list) into the form on sheet3 (new sheet) in cell D4.
Sub CreateSheetsFromEmployeeList()
Dim nameSource
Dim nameColumn
Dim nameStartRow As Long
Dim nameEndRow As Long
Dim employeeName As String
Dim newSheet As Worksheet
nameSource = "Ayre"
nameColumn = "A"
nameStartRow = 2
nameEndRow = Worksheets(nameSource).Cells(Rows.Count, nameColumn).End(xlUp).Row
Do While (nameStartRow <= nameEndRow)
employeeName = Sheets(nameSource).Cells(nameStartRow, nameColumn)
employeeName = Trim(employeeName)
If (employeeName <> vbNullString) Then
On Error Resume Next 'do not throw error
Err.Clear 'clear any existing error
Sheets(employeeName).Name = employeeName
If (Err.Number > 0) Then
Err.Clear
On Error GoTo -1
Set newSheet = Sheets.Add(After:=Sheets(Sheets.Count))
newSheet.Name = employeeName
Sheets(nameSource).Activate
LastCol = ActiveSheet.Cells(nameStartRow, Application.Columns.Count).End(xlToLeft).Column
Range(Cells(nameStartRow, 1), Cells(nameStartRow, LastCol)).Select
Selection.Copy
Sheets(employeeName).Activate 'NEW
Sheets(employeeName).Cells(1, "A").PasteSpecial
[a1].Select 'NEW
Application.CutCopyMode = False
Sheets(employeeName).Columns("A:K").AutoFit
End If
End If
nameStartRow = nameStartRow + 1
Loop
End Sub
Record a macro
When you record a macro, the macro recorder records all the steps required to complete the actions that you want your macro to perform. Iterate your action once, stop recording, then view the macro to repeat and build out your final automation macro.
This code demonstrates the basic principles you need:
Sub ExampleForAngel()
Dim names As Worksheet
Set names = Worksheets("Sheet1")
Dim eval As Worksheet
Set eval = Worksheets("Sheet2")
Dim index As Long
index = 0
Dim name As String
While (names.Range("A1").Offset(index, 0).Value <> "")
name = names.Range("A1").Offset(index, 0)
eval.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.name = name
ActiveSheet.Range("A2").Value = name
index = index + 1
Wend
End Sub
This puzzle is getting on my nerves now, as a beginning VBA Excel user with a lot of ambition to automize things... (Maybe a bit too ambitious :) )
The things I've managed this far are: creating a new file with a worksheet for every company, containing all current available data.
A control sheet where I can select which stakeholder should receive which sheet(s), with which text and when.
This all works fine but I want to add graphs to the data to show what's going on over time.
The problem is:
- looping through a variable set of data every month there's a new column added so the range of columns should be flexible.
- the number of rows per company isn't predefined and may vary month-over-month
- the number of companies where a worksheet is created for may vary as well
My intention is to:
- create graphs for each unique value in Column D
- name the graphs (title) with the unique value in column D
- name the new created tab with the name of the Company in column A (let's say: 'Company A - graphs' as a sheet name)
- include all graphs from the current sheet in one sheet (the information on the current sheet is of ONE company)
- go to the next sheet and do the same (loop) until all sheets are done
- add another sheet with all sheet names that are currently in the file (existing + created)
- the label of the Y-values is in column G ('Name')
- the Y-values are in the columns H and further and row 2 and all the way down (flexible)
- the headers are in row 1 --> only the months (H >>) should be included on the X-axis
- So the information in the columns A:F shouldn't be used other than mentioned above
I got quite a piece of script but I'm on a dead end street. Any help would be very much appreciated!
If you have any questions please let me know.
Many many thanks in advance!
Wouter :-)
P.S.: Here's the file: http://we.tl/786d6b6cs0
Sub WJS_CreateGraphs()
Response = MsgBox("Are you sure you want to create graphs for all worksheets?", vbYesNo, "Graph Creator")
If Response = vbNo Then
Exit Sub
End If
' ------------------------------------ Now we will create pivot tables for all scenario's
Dim WS_Count As Integer
Dim C As Integer
' Set WS_Count equal to the number of worksheets in the active workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For C = 1 To WS_Count
Dim I As Integer
Dim selecta As Range
Dim grFilter As Range, grUniques As Range
Dim grCell As Range, grCounter As Integer
Dim arow As Integer
Dim acol As Integer
Dim StartPoint As Integer
Dim EndPoint As Integer
Dim rStartPoint As Integer
Dim rEndPoint As Integer
ActiveSheet.Range("D1").Select
Set selecta = Range(Selection, ActiveCell.SpecialCells(xlLastCell))
Set grFilter = Range("D1", Range("D" & Rows.Count).End(xlUp))
With grFilter
' Filter column A to show only one of each item (uniques) in column A
.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
' Set a variable to the Unique values
Set grUniques = Range("D2", Range("D" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
' Filter, Copy, and Paste each unique to its' own sheet in the new workbook
For Each cell In grUniques
counter = counter + 1
'NOTE - this filter is on column D(field:=1), to change
'to a different column you need to change the field number relative to the Unique Value range above
grFilter.AutoFilter field:=1, Criteria1:=cell.Value
'********************************************************************************************************************************
temp_StartPoint = 2
temp_EndPoint = ActiveSheet.UsedRange.Rows.Count
For arow = temp_StartPoint To temp_EndPoint
StartPoint = 2
EndPoint = ActiveSheet.UsedRange.Rows.Count
FirstColumn = 7
LastColumn = ActiveSheet.UsedRange.Columns.Count
' remember the sheet to return to, this is the current active sheet --> after creating a graph VBA will return to this sheet
MyPrevSheet = ActiveSheet.name
Charts.Add
ActiveChart.ChartArea.Select
ActiveChart.ChartType = xlLine 'Type of graph
' Return to previous sheet
If Len(MyPrevSheet) > 0 Then
Sheets(MyPrevSheet).Activate
Else
MsgBox "You have not switched sheets yet since opening the file!"
End If
ActiveChart.SetSourceData Source:=Range(Cells(StartPoint, FirstColumn) & ":" & Cells(EndPoint, LastColumn))
', PlotBy:=xlRows 'data source
ActiveChart.SeriesCollection(1).XValues = ActiveSheets.Range(FirstColumn & "1:" & Cells(LastColumn, 1))
'naming the x-axis
ActiveChart.SeriesCollection(1).name = "Spwr" ' Name of 1st data series 1
ActiveSheet.ShowAllData
On Error Resume Next
With ActiveChart.SeriesCollection(1) 'put labels on 1st data series
.HasDataLabels = True
.DataLabels.NumberFormat = "##"
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.PlotArea.Select ' Background of graph
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).name = "salespower"
ActiveChart.SeriesCollection(2).Values = ActiveSheets.Range("G2:m2")
With ActiveChart.SeriesCollection(2) 'put labels on 2nd line
.HasDataLabels = True
.DataLabels.NumberFormat = "##"
End With
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).name = "Tests"
ActiveChart.SeriesCollection(3).Values = ActiveSheets.Range("G2:m2")
With ActiveChart.SeriesCollection(3) 'put labels on 3rd line
.HasDataLabels = True
.DataLabels.NumberFormat = "##"
End With
ActiveChart.Legend.Position = xlLegendPositionBottom
ActiveChart.HasTitle = True
ChartTitle = "Naam van de chart"
Next arow
Next cell
rngFilter.Parent.AutoFilterMode = False
Application.ScreenUpdating = True
'***********************************************************************************************************************************************
End With
Next C
End Sub