KWilkinson
New Member
- Joined
- Dec 9, 2016
- Messages
- 11
Hi all,
I'm fairly new to VBA and trying to write some basic macros to reduce some drudgery when working with a few of our standard spreadsheets. As part of this I'm trying to create a new sheet which needs to be named based on data in 2 separate cells.
The code is pretty basis but I can see what I'm doing wrong when it comes to naming the sheet - can anyone assist and point me in the right direction?
Sub CreateNewSheet()
Dim Sheetname As String
Dim ws As Worksheet
Sheeetname = Worksheets("Proposed").Cells(2, "A") & "-" & Cells(2, "B").Value
Set ws = ThisWorkbook.Sheets.Add(After:= _
ThisWorkbook.Sheets("Proposed"))
ws.Name = Sheetname
End Sub
I'm fairly new to VBA and trying to write some basic macros to reduce some drudgery when working with a few of our standard spreadsheets. As part of this I'm trying to create a new sheet which needs to be named based on data in 2 separate cells.
The code is pretty basis but I can see what I'm doing wrong when it comes to naming the sheet - can anyone assist and point me in the right direction?
Sub CreateNewSheet()
Dim Sheetname As String
Dim ws As Worksheet
Sheeetname = Worksheets("Proposed").Cells(2, "A") & "-" & Cells(2, "B").Value
Set ws = ThisWorkbook.Sheets.Add(After:= _
ThisWorkbook.Sheets("Proposed"))
ws.Name = Sheetname
End Sub