Hello,
I’m using the following code to save an Excel file:
ActiveWorkbook.SaveAs “C:temp” & Range(“H2”).Value & “-” & Format(Date, “mmm dd, yyyy”)
(the cell reference refers to a unique number)
Everything is working great, and it’s doing what I want, but now I’ve found out that my coworkers want to include more information in the name of the file. No problem grabbing another cell reference, but what they need is only part of a cell. And the part of the cell needed varies from one day to the next.
The cell I will be pulling from is “G2” and is a city and state followed by hyphen and then a short description. I just need the city and state.
I know I can use a formula in the spreadsheet itself to pull the information I need, but I’m wondering if there is a way to put it into some code and avoid cluttering up the spreadsheet.
Here are a couple of examples:
Madison, WI – Run around in circles
San Diego, CA – Jump up and down
Truth or Consequences, NM – Sit down on the couch
I just need the city and state (everything before the hypen)
Any ideas on grabbing what I need using VBA?
Thanks!