CONCATENATE & IF statement in VBA

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
Hi Guys,

I am currently working on a holiday request form and I am at the very early stages of it. I was just wondering if anyone could help me with integrating the below formula into VBA please as I am a complete newbie.

=IF(C21 ="Jan","01",IF(C21 ="Feb","02", IF(C21 ="Mar","03" ,IF(C21 ="Apr","04""Month Required")))

=IF(E21 ="Jan","01",IF(E21 ="Feb","02", IF(E21 ="Mar","03" ,IF(E21 ="Apr","04""Month Required")))

then Concatenate the results from C21 & D21 into H21
E21 & F21 into I21
And Change into Date format.

Any help would be greatly appreciated.

Bloodmilksky
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
if you just use something different consider a date of the event

use =MONTH(C21), no conversion necessary, not mucking around with written months and you have the real result
 
Upvote 0
say Jon wanted to start leave on 21/6/2016 or 21 jun 2016 and that entered in a location example A1 then where you want you month number to appear you use =MONTH(A1) and it will return 6, no IF statements, just converting a date number to a month number
 
Upvote 0
thats awesome thank you Mole999 ^_^ has given me a new take on the Form. if I wanted to set this up in VB without a formula, would you know the Syntax for that?
 
Upvote 0
honestly i hit macro record and then just record me changing that cell which might give you
ActiveCell.FormulaR1C1 = "=MONTH(R[-1]C[-6])"
that works but it dosen't reference A1, it references 1 above and six left, also if the cell you are looking at is empty you will get a 1 so it might be mistaken for January,
and you need to change the cell to =IF(A1="","",MONTH(A1)) to test for a value,
that can be taken further to ensure you are getting a number there, it is seemingly endless
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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