Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-29-2020, 06:10 AM
p45cal's Avatar
p45cal p45cal is offline Problems with vba frequency distribution histogram Windows 10 Problems with vba frequency distribution histogram Office 2019
Expert
 
Join Date: Apr 2014
Posts: 948
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Quote:
Originally Posted by leeqiang View Post
The reason for using vba instead of the perspective chart is that when I change the two manually entered values mentioned above, the code can automatically generate new data and charts. Thank you!
I was asking if the 3 for the group interval was always 3 or if it needed to be calculated from the source data or from perhaps a cell value in the sheet. As it is I've used a hard-coded 3.
Reply With Quote
  #2  
Old 08-30-2020, 06:23 PM
leeqiang leeqiang is offline Problems with vba frequency distribution histogram Windows 10 Problems with vba frequency distribution histogram Office 2019
Advanced Beginner
Problems with vba frequency distribution histogram
 
Join Date: Aug 2020
Posts: 49
leeqiang is on a distinguished road
Default

Quote:
Originally Posted by p45cal View Post
I was asking if the 3 for the group interval was always 3 or if it needed to be calculated from the source data or from perhaps a cell value in the sheet. As it is I've used a hard-coded 3.

In my code, both the starting value and the group pitch are manually entered. Specifically, enter the group spacing in cell B8, and enter the starting data value in cell C1. A judgment condition is also set. When cells C1 and C2 have data and cell B8 has no input data, the group distance can be obtained by subtracting the value of cell C1 from the value of cell C2. Then automatically generate all the separation points of the data, and then other data.

These logics are reflected in my following code:
p = ActiveSheet.Cells.Rows.Count
q = ActiveSheet.Cells(p, 3).End(xlUp).Row
If q >= 2 Then
groupsp = Cells(q, 3) - Cells(q - 1, 3)
[b8] = groupsp
Else
groupsp = [b8].Value

End If
'Range("c3:C" & q).Clear
If q <= 1 And [b8].Value = "" Then Exit Sub
If [c1].Value = "" And [b8].Value <> "" Then Exit Sub
For drow = q + 1 To ActiveSheet.Cells.Rows.Count
Cells(drow, 3) = Cells(drow - 1, 3) + groupsp
If Cells(drow, 3) = vMax Then Exit For
If Cells(drow, 3) > vMax Then Exit For
Next drow

'MsgBox groupsp
[b10] = ActiveSheet.Cells(p, 3).End(xlUp).Row - 1
End Sub
Reply With Quote
  #3  
Old 08-30-2020, 06:38 PM
leeqiang leeqiang is offline Problems with vba frequency distribution histogram Windows 10 Problems with vba frequency distribution histogram Office 2019
Advanced Beginner
Problems with vba frequency distribution histogram
 
Join Date: Aug 2020
Posts: 49
leeqiang is on a distinguished road
Default

Quote:
Originally Posted by p45cal View Post
I was asking if the 3 for the group interval was always 3 or if it needed to be calculated from the source data or from perhaps a cell value in the sheet. As it is I've used a hard-coded 3.

Your code is very concise and clear. You set the group distance to 3, and the data start value is automatically generated according to the calculation. I want to be able to manually input the two values of the data start value and the data group distance, which can be entered in a dialog box. Thank you!
Reply With Quote
  #4  
Old 08-30-2020, 06:44 PM
leeqiang leeqiang is offline Problems with vba frequency distribution histogram Windows 10 Problems with vba frequency distribution histogram Office 2019
Advanced Beginner
Problems with vba frequency distribution histogram
 
Join Date: Aug 2020
Posts: 49
leeqiang is on a distinguished road
Default

Quote:
Originally Posted by leeqiang View Post
Your code is very concise and clear. You set the group distance to 3, and the data start value is automatically generated according to the calculation. I want to be able to manually input the two values of the data start value and the data group distance, which can be entered in a dialog box. Thank you!





Manually input the two values of the data start value and the data group distance, you can set a dialog box to input. This is because these two values can be entered according to the actual situation, which has greater flexibility. The function of the code is to quickly generate a series of data and charts in time after changing these two values.

If the pivot table can automatically change into a new chart with the generated data, it is also possible to use the pivot table to generate the chart.
Reply With Quote
Reply

Tags
histogram



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to draw the histogram? leeqiang Excel Programming 1 08-27-2020 05:19 PM
Problems with vba frequency distribution histogram Frequency of Count Ifs keeble Excel 4 02-01-2017 10:33 AM
Formula to calculate Frequency lwls Excel 1 03-30-2015 05:40 AM
Problems with vba frequency distribution histogram Trying to count frequency borninscorpio Excel 4 07-31-2013 12:44 AM
Frequency of a name bryant03 Excel 1 06-27-2012 10:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft