Re: Help with VBA linked to a check box to save excel file
I wanted to add a bit more clarity to were the data is coming from on the sheet and also a bit more information on the network path that the file is saved to...
On the sheet, I have a date in cell e4 formatted as mm,dd,yy.
We rename the sheet from "Sheet 1" to a name (last name, first name). It's always: Last name comma space first name. This sheet name is then transposed to cell b7 with the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=MID(CELL[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]"filename",[/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]A2[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],FIND[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]"]",CELL[/FONT][/COLOR][COLOR=#AB30D6][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]"filename",[/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]A2[/FONT][/COLOR][COLOR=#AB30D6][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]+1,20)[/FONT][/COLOR]
Then, in cell b6 we take part of that sheet name and fill a cell with the first name using the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=RIGHT([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]B7[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],LEN[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]B7[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]-FIND[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]", ",[/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]B7[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]-1)[/FONT][/COLOR]
Then, in cell d6 we take the rest of that sheet name and fill a cell with the last name using the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=LEFT([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]B7[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],FIND[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]([/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]", ",[/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]B7[/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande])[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]-1)[/FONT][/COLOR]
We have 2 other date cells, I4 & I5, that are formatted the same as e4 (mm,dd,yy).
Ive used this data to concatenate it a number of different ways, in a separate area of the sheet that are identical to many of my needs....file name, file paths, etc.
In cell aa1, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=TEXT([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]E4[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],"mmmm")[/FONT][/COLOR]
In cell aa1, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=TEXT([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]E4[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],"dd")[/FONT][/COLOR]
In cell aa3, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=TEXT([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]E4[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande],"yyyy")[/FONT][/COLOR]
In cell ac1, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=CONCATENATE([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]AA1[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande]," ", [/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]AA3[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande])[/FONT][/COLOR]
In cell ac2, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=CONCATENATE([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]AA1[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], " ", [/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]AA2[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], ",", [/FONT][/COLOR][COLOR=#AB30D6][FONT=Lucida Grande]AA3[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande])[/FONT][/COLOR]
In cell ac3, I have the formula:
Code:
[COLOR=#000000][FONT=Lucida Grande]=CONCATENATE([/FONT][/COLOR][COLOR=#0057D6][FONT=Lucida Grande]D6[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], ", ", [/FONT][/COLOR][COLOR=#006107][FONT=Lucida Grande]B6[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], " ", [/FONT][/COLOR][COLOR=#AB30D6][FONT=Lucida Grande]AA1[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], "-", [/FONT][/COLOR][COLOR=#A54A29][FONT=Lucida Grande]AA2[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande], "-", [/FONT][/COLOR][COLOR=#33AF4A][FONT=Lucida Grande]AA3[/FONT][/COLOR][COLOR=#000000][FONT=Lucida Grande])[/FONT][/COLOR]
I tried to set these cells up so they can be used in the VBA like:
Code:
[COLOR=#454545][FONT=Helvetica Neue][SIZE=2]ChDir “z:\pathfolder1\pathfolder2\pathfolder3\” & Range(“AC1”)\” & Range(“AC2”)\.Value, FileFormat:=51"[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT=Helvetica Neue][SIZE=2] thisfile = Range("AC3").Value[/SIZE][/FONT][/COLOR]
File paths 1,2, and 3 will have constant names. File paths 4 and 5 can be determined (and are currently named as such) by cells AC1 and AC2, respectively.
The file name to go into file path 5 is determined and named by cell AC3.
I'm using excel for Mac 2011, but some on our network are using MS 365 with varying versions. So far, we're not having any access or usability issues with any of the users because of this. Also, I'm very new (< 1 month) to VBA coding and have only read what I can find here and other Google searches, as well as a lot of an VBA tutorial by Tom Urtis. So, I apologize if the questions, or my thought processes leave a lot to be desired. Thanks for any help/education in advance.