Macro for downloading once per day - avoiding data being overwritten?

Zhevr

New Member
Joined
Apr 19, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,
I'm creating an excel sheet which is downloading air quality data once per day and calculating the average from the last 24 hours.
I'm a newbie with macros and am currently setting it up as a download when the document is opened and a macro to clean out all the unnecessary input imported and calculating the average. I want that average to be transferred to a separate sheet with the date of the current day. Since the macro will run once a day it won't be a loop. I want the result to be a table with dates and averages from all the days the macro was run.

How do I make sure the data from the day before isn't overwritten when setting up the macro?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Assuming you are writing the data to a new sheet ( I assumed sheet2) starting in column A, you can detect which is the last row with data in it using these lines of code:
VBA Code:
With Worksheets("sheet2")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
End with
Having found the last row you just write your new data into the next row, save and repeat the next day
 
Upvote 0

Forum statistics

Threads
1,215,742
Messages
6,126,602
Members
449,321
Latest member
syzer

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