Regarding Select Case,
The code you have posted will not work, because :
a. You must pass a variable (or expression) to the Select case on the first line. You have passed it the constant TRUE.
b.The individual Case statements are not values against which the Select Case variable can be tested.
Each case statement is like an if(b=a, then do this)
where an individual case statement is the' IF(b=' part
and the Select case is the a
The next Case statement is IF(c=a, then do this
Only the code after ONE Case statement is run.
The idea of Select Case is that you pass it a variable, which could be a variable that changes during the execution of your program or it could be the value of a Cell.
Select case then goes down each Case statement to see if the value of the variable passed to it matches the Case statement. If it matches, it runs any lines of code from the matching Case until it encounters the next case statement, and then exits the Select Case structure
Here is a simple example:
This subroutine sets a value in the Active Cell and then the Select Case takes the value in the Active cell and makes comparisons.
Here it finds no matches, and runs the code following Case Else
outputting the message
"Active cell doesn't contain a, b or c"
ActiveCell.Value = "v"
Select Case ActiveCell
MsgBox "Active cell contains a"
MsgBox "Active cell contains b"
MsgBox "Active cell contains c"
MsgBox "Active cell doesn't contain a, b or c"
To be able to help, you need to say what you are trying to do, rather than just saying some code you have written doesn't work. Without knowing what you intended your code to do, it is very hard to propose a solution - which we would like to do.
It looks as though one of the things you are trying to do is to copy the range J3:J18 on the Worksheet named "Current" and paste it into the Range B2:B17 on the "YTD" worksheet.
This can be done with one line:
I note that you are using PasteSpecial with PasteValues. Is this what you intended - because you now loose the links to the source data. If the source data changes, the pasted cells will not change.
I suspect that your code has come in part from recording a Macro.
Recording macros can be a useful way to find out how Excel works, but there are several issues such as:
1. It uses a lot of Select statements, which are rarely required in VBA
2. It will include lots of default values which are not needed, such as Operation:=xlNone
Anyway give us some specifics to work on.