Syntax problem

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,362
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this line of code:

.Range("B23").Value = "October " & Range("E18").Value

E18 has the current year and I need the range in cell B23 to be October & the following year.
It works to get the current year in B23 but I wasn't sure of the syntax to get the following year.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I am sure I already tried that option and it wouldn't work. Well, thanks anyway.
 
Upvote 0
How is E18 derived ?
By formula or manually typed in.
Also, is it only the year in E18 and nothing else ?
 
Upvote 0
Ok, In that case what is "wouldn't work" ?
Wrong outcome ?
Nothing ?


Have you formatted B23 to Text ??
 
Upvote 0
Fine for me too....but just trying to eliminate ...
 
Upvote 0
I have this code and it won't change the year in cell B20 from July 2018 to July 2019 and the year is not changing. Is there something wrong with the syntax?

Code:
Private Sub cmdNewTool_Click()
Dim newDoc As String
    newDoc = txtNewDoc.Text & ".xlsm"
  
    ActiveWorkbook.SaveCopyAs Filename:=txtNewDoc.Text & ".xlsm"
    Workbooks.Open Filename:=newDoc
    
    With Worksheets("home")
        .Range("B20").Value = "July " & Range("E18").Value + 1

    End With


End Sub
 
Upvote 0
Thanks for this guys, I am learning so much! Just been told that I don't need the text box to work out the year of the file as the new file will always be 1 year ahead of the current file. I have this code but I need a hand with the syntax please.

Code:
Private Sub cmdNewTool_Click()
Dim newDoc As String
    newDoc = "NPSS work allocation sheet " & Year() + 1 & ".xlsm"
  
    ActiveWorkbook.SaveCopyAs Filename:=newDoc
    
    Workbooks.Open Filename:=newDoc
    
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top