Thread: Ron de Bruin
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Ron de Bruin

Hi Steve

Not much time on this moment (my birthday today)

But this is my idea to save your data to a new file in the same cell locations
It not save the names but we not need that because the data is in the same cells.

The Data is on a sheet named Sheet1 in my example and I save the files in C:\ with a date/time stamp

Try it and let me know if this is a good start

Sub Copy_named_ranges()
Dim ws As Worksheet
Dim wb As Workbook
Dim Nwb As Workbook
Dim Nme As name

Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
Set Nwb = Workbooks.Add(xlWBATWorksheet)
wb.Activate

For Each Nme In wb.Names
If Left(Nme, Len(ws.name) + 1) = "=" & ws.name Then
With ws.Range(Nme.name)
.Copy Destination:=Nwb.Sheets(1).Range(.Address)
End With
End If
Next

Nwb.SaveAs "C:\" & Format(Now, "dd-mmm-yy h-mm-ss") & ".xls"
Nwb.Close False
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Ron de Bruin" wrote in message ...
OK, I look at it after dinner


--
Regards Ron de Bruin
http://www.rondebruin.nl



"steve" wrote in message ...
there about 30 user input cells that I have named. (these are individual cells)

then there are 3 "matrices" of data. they are 10 cells X 10 cells each.
for example, I have named cells A1:J10 "EpoxyMatrix". this whole area is
yellow for userinput.

so in all, there are about 35 names that will be copied. down the road,
this may increase or decrease.

Thanks,
Steve

"Ron de Bruin" wrote:

How many cells are there in all range names together

--
Regards Ron de Bruin
http://www.rondebruin.nl



"steve" wrote in message ...
I'm sorry for singling you out, but you've always given me great solutions.
This piece of code will be very crucial in my application.

On a spreadsheet, I have colored yellow every range that i consider to be
User Input. I have also re-named each of these ranges.

I want a button to create a new workbook. I want to copy the names of the
ranges that are user input. I also want to copy their values. This is so
later, I can call on this file and re-use this user input.

One of the big issues I am encountering is that some of the Named Ranges are
larger than just a single cell. I have 3 particular ranges that are 10 cells
X 10 cells.

Later, if the user wants to call on one of these files containing the user
input, I want to cycle through the names of the ranges that we saved, and
copy them back to the yellow cells of the same name. If for some reason,
this yellow cell has changed names or been deleted, I want to just skip that
and move to the next.

Thanks for any help!
Steve