Having trouble with autonaming sheets in a workbook.

  • Thread starter Thread starter ghstridr
  • Start date Start date
G

ghstridr

The code I've got:
Dim Cell_Location As Integer
Dim Sheet_Name As Integer
Dim Selection_Copy As String
Cell_Location = 1
Sheet_Name = 1
Selection_Copy = ""
'
Sheets("Names").Select
Range("A" & Cell_Location).Select
Selection.Copy
Sheets("Sheet" & Sheet_Name).Select
Selection_Copy.GetFromClipboard
Sheets("Sheet" & Sheet_Name).Name = Selection_Copy
'
Cell_Location = Cell_Location + 1
Sheet_Name = Sheet_Name + 1
------------------------------------------------------End Code
What I'd like to do is get the 'name' from the clipboard and paste i
as the name of the sheet. I think I'm close, I'm confused on th
useage of GetFromClipboard
 
Hi
no need to use copy/paste and the clipboard for this. Try the
following:
sub foo()
Dim new_sheetname
Dim Cell_Location As Integer
Dim Sheet_Name As Integer

Cell_Location = 1
Sheet_Name = 1

new_sheetname = worksheets("Names").range("A" & cell_location).value
worksheets("sheet" & sheet_name).name = new_sheetname
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top