ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using cell references in Excel Macros (https://www.excelbanter.com/excel-programming/307202-using-cell-references-excel-macros.html)

Michelle Ann

Using cell references in Excel Macros
 
I'm trying to write a macro that will add a new worksheet to an existin
workbook, rename the new sheet with a name that's in a range of cell
(A5:D5 in this case) return to the original worksheet and clear th
infomation from selected cells.
Everything works, except that the line which renames the ne
worksheet has a literal string (pervious cell information) in it. Ho
can I make reference to the cell which contains the date instead of th
data itself, so tha each time the macro runs it'll name the sheet wit
the new data? Or is this even possible?

Thanking you
Michelle An

--
Message posted from http://www.ExcelForum.com


Debra Dalgleish

Using cell references in Excel Macros
 
You can refer to a cell's value when you name the sheet:

Dim ws As Worksheet
Set ws = Worksheets.Add
ws.Name = Sheets("Sheet1").Range("C3").Value


Michelle Ann < wrote:
I'm trying to write a macro that will add a new worksheet to an existing
workbook, rename the new sheet with a name that's in a range of cells
(A5:D5 in this case) return to the original worksheet and clear the
infomation from selected cells.
Everything works, except that the line which renames the new
worksheet has a literal string (pervious cell information) in it. How
can I make reference to the cell which contains the date instead of the
data itself, so tha each time the macro runs it'll name the sheet with
the new data? Or is this even possible?


--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com