bleached88
New Member
- Joined
- Apr 21, 2015
- Messages
- 4
Hi guys,
this is quite a complex problem and seeing as I haven't used vba since I was in school I might be a little bit out of my league. I've designed two spreadsheets to monitor task counting where I work, one workbook for a daily analysis and another for monthly which we will be pasting values only from the daily workbook into. I'm trying to protect these workbooks so that nobody can delete any of the formulas, so I've been creating buttons and writing macros that unprotect the data, copy information across, then reprotect the data afterwards. These work well but the issue I've come across is this; there are buttons next to every day on the monthly log that basically do the same thing, copy info from the daily tracker into the relevant block of cells next to each button, one for each day so 31 in all. However, if someone were to press the wrong button next to the wrong day then the info copied over from the daily spreadsheet will replace data already in the monthly tracker, which then can't be undone. My idea is to add an extra layer of validation into the macro of the button that checks the date on the monthly tracker vs the date on the daily tracker before executing the copying of the data. This is where it gets complex because I'm comparing the values of two cells in two separate workbooks to generate another macro. In my head the idea would be something like this in simple terms:
Sub check_date()
If daily.range("B5") = monthly.range("B225")
Then run"copy_data"
end sub
I realise there's probably a lot more to it than that because I'm comparing values from two different workbooks. On the daily spreadsheet, the date in the cell is generated by =TODAY() so I don't know if this will affect anything? As I said I've already written the macro for "copy_data" and it works perfectly. Any help would be much appreciated as I'm a little bit out of my league thanks in advance
this is quite a complex problem and seeing as I haven't used vba since I was in school I might be a little bit out of my league. I've designed two spreadsheets to monitor task counting where I work, one workbook for a daily analysis and another for monthly which we will be pasting values only from the daily workbook into. I'm trying to protect these workbooks so that nobody can delete any of the formulas, so I've been creating buttons and writing macros that unprotect the data, copy information across, then reprotect the data afterwards. These work well but the issue I've come across is this; there are buttons next to every day on the monthly log that basically do the same thing, copy info from the daily tracker into the relevant block of cells next to each button, one for each day so 31 in all. However, if someone were to press the wrong button next to the wrong day then the info copied over from the daily spreadsheet will replace data already in the monthly tracker, which then can't be undone. My idea is to add an extra layer of validation into the macro of the button that checks the date on the monthly tracker vs the date on the daily tracker before executing the copying of the data. This is where it gets complex because I'm comparing the values of two cells in two separate workbooks to generate another macro. In my head the idea would be something like this in simple terms:
Sub check_date()
If daily.range("B5") = monthly.range("B225")
Then run"copy_data"
end sub
I realise there's probably a lot more to it than that because I'm comparing values from two different workbooks. On the daily spreadsheet, the date in the cell is generated by =TODAY() so I don't know if this will affect anything? As I said I've already written the macro for "copy_data" and it works perfectly. Any help would be much appreciated as I'm a little bit out of my league thanks in advance