Hello all,
This is my first post borne out of sheer and utter frustration trying to get to grips with VBA.
I've been dipping in and out of VBA in my job as an Acoustic Engineer trying to devise code to replace a lot of the repetitive tasks in terms of data handling that we do.
As an ongoing project, i'm trying to create a Macro that can create a chart of survey data. Our surveys consists of different number of rows each time as it depends on how long the survey was carried out for. I have the following code (see below) to essentially create the chart irrespective of the size of the data as it supposed to count to the end of the column until it finds a blank cell.
The Cell F5 is the start of the column that defines the X axis, which is the date and the G5 cell is the start of the column where the survey data is in.
When I run this code it only gets to about half way and then stops. Any ideas why this might be?
I got the basic code off another website so I am confident the counter works and the main loop is based on a recording I made to make the chart.
Sub Create_Chart()
Application.ScreenUpdating = False
'Define the Variables
'-------------------------
Dim counter As Long
Dim totcounter As Long
'Initialise the Variables
'-----------------------
counter = 1
totcounter = 1
Sheets("Raw Data Sheet").Select
'Total Counter to tell macro when to stop
'-----------------------------------------
Do Until IsEmpty(Cells(totcounter, 1)) = True
totcounter = totcounter + 1
Loop
totcounter = totcounter - 1
'Main Loop of Programme
'----------------------------------
Range("F5:G5" & totcounter).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Range("'Raw Data Sheet'!$F$5:$G$5" & totcounter)
Application.ScreenUpdating = True
End Sub
Bookmarks