Extract all unique values from a range (multiple columns and rows) to another location while counting the number of entries

masud8956

Board Regular
Joined
Oct 22, 2016
Messages
163
Office Version
  1. 2016
  2. 2011
  3. 2007
Platform
  1. Windows
Hi,

I have 2 identical ranges (A25:BT44) in two different sheets (1 & 2). Users are allowed to enter data in any cell of the range A25:BT44 of Sheet1. The purpose of the same range in Sheet2 is to stamp dates of data entry. So I have the dates of each data entry in the corresponding cells of the same range in Sheet2. The range in both the sheets will have random blank cells. The range in Sheet2 looks like this:

ABCD....BT
2503 NOV 1906 NOV 1903 NOV 19
2604 NOV 19
2704 NOV 1903 NOV 19
2806 NOV 1904 Nov 19
....
04 NOV 19​
4404 NOV 19

<tbody>
</tbody>


What formula can I use to get a list of all unique dates along with total number of entries of the same day in that specific range? I expect a result as following:

ABC
1DateNo of Entries
203 Nov 193
304 Nov 195
406 Nov 192

<tbody>
</tbody>

After extracting the result I intend to use them as chart to display amount of job done per day vs a specific target.

I do not prefer VBA unless that is the only option.

TIA.
 
Last edited:
Have you now changed from wanting the date stamps on Sheet2 and want them on the same sheet as the original data entry or is that just because of the code you found? It would be easy to have them in the identical range in another sheet like your original setup.
 
Last edited:
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Have you now changed from wanting the date stamps on Sheet2 and want them on the same sheet as the original data entry or is that just because of the code you found? It would be easy to have them in the identical range in another sheet like your original setup.

Actually Yes! I have done it because of the code. I am not very confident on modifying VBA code. But if keeping the source and destination range identical in different sheets is easier then that is absolutely fine.

Here is what I am looking for:

1. My data range is E5:BX24 for Sheets 1 and 2 (had to change a bit from #1 ). In sheet1 users will enter data and I want the date stamped on the identical cells of sheet2.
2. I want the date stamp removed from E5:BX24 at sheet2 if user deletes entries at sheet1.
3. Both the sheets are password protected (same password). The wordbook will also be protected (same password). Sheet2 will be hidden as well. Macro will be password protected as well (same password).
4. I am using Excel 2016.

What code should I use for my requirements?

Thanks again!
 
Upvote 0
In Sheet2, you can still have the formulas set up as before, but with the new range of E5:BX24

To get/clear the date stamps you can use this worksheet change code in Sheet1.
To implement ..
1. Right click the Sheet1 name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Edit the password for Sheet2 (twice).
4. Close the Visual Basic window & test.

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim ws2 As Worksheet
  Dim myRange As Range, Changed As Range, cel As Range
  
  Set myRange = Range("E5:BX24")
  Set ws2 = Sheets("Sheet2")
  Set Changed = Intersect(myRange, Target)
  If Not Changed Is Nothing Then
    ws2.Unprotect Password:="yourpassword"
    For Each cel In Changed
      ws2.Range(cel.Address).Value = IIf(Len(cel.Value) > 0, Date, "")
    Next cel
    ws2.Protect Password:="yourpassword"
  End If
End Sub
 
Upvote 0
Solution
The code works perfectly!

Thank you again!!

Some how the code was giving error with
Code:
[COLOR=#333333]Set ws2 = Sheets("Sheet2")[/COLOR]

[Then I replaced "Sheet2" with the sheet name and it works just fine. I have rechecked....the destination sheet is actually Sheet2.]
 
Upvote 0
[Then I replaced "Sheet2" with the sheet name and it works just fine. I have rechecked....the destination sheet is actually Sheet2.]
Does that mean Sheet2 was the sheets codename not its tab name?

In any case, is everything working properly now?
 
Last edited:
Upvote 0
The code was giving error. After debugging it pointed to:

Code:
[COLOR=#333333]Set ws2 = Sheets("Sheet2")[/COLOR]

Sheet2 name is "DATA". Then I changed the line as:

Code:
[COLOR=#333333]Set ws2 = Sheets("DATA")[/COLOR]

And it is working perfectly now.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top