Format syntax problem

VBAProIWish

Well-known Member
Joined
Jul 6, 2009
Messages
1,027
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have been trying many different ways to get this format to work but can't seem to get it right. Here's a couple I tried but didn't work...


Code:
.Range("A2:A" & .Range("B" & Rows.Count).End(xlUp).Row).Selection.NumberFormat = "yyyy-mm, mmm"


Code:
Selection.Range("A2:A" & .Range("B" & Rows.Count).End(xlUp).Row).Selection.NumberFormat = "yyyy-mm, mmm"

I'm trying to copy cell A1 using a custom format in column A, equal to the bottom-most row with data in column B.

Thanks much
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try

Code:
.Range("A2:A" & .Range("B" & Rows.Count).End(xlUp).Row).NumberFormat = "yyyy-mm, mmm"
 
Upvote 0
VoG,

Oops, My fault for not wording this correctly.

Yes, that changed the format, but the cells are all blank. That is because I FORGOT to mention that I want to copy the cell in A2 (which already has the correct date and format) and paste the SAME DATE AND FORMAT in cell A2 equal to the bottom-most row of data in column B.

So, in laymens terms...

1. Copy A2
2. Paste A2 to all cells in Column A but stop at bottom-most row of data in column B.


Sorry for the confusion
 
Upvote 0
Try

Code:
.Range("A2:A" & .Range("B" & Rows.Count).End(xlUp).Row).NumberFormat = "yyyy-mm, mmm"
.Range("A3:A" & .Range("B" & Rows.Count).End(xlUp).Row).Value = .Range("A2").Value
 
Upvote 0
Freakin Amazing, I wish I could get this stuff on the first try like you guys. I can only dream it will be soon.


SINCE YOU'RE GOING STRONG, ONE MORE ADDITION?...


How about also copying the borders from A2 down as well?

I would imagine it would be another short line of code similiar to the first two?


Thank you for this VoG, it's a big help :)
 
Upvote 0
Instead of the above try

Code:
.Range("A2").Copy Destination:=.Range("A2:A" & .Range("B" & Rows.Count).End(xlUp).Row)
 
Upvote 0
Alright, now you're just showing off! ;)

WwoowW

Are you kidding me, one line of code!​

That is just A W E S O M E!:biggrin:


Thank you Thank you, this one's going in my "Code Hall of Fame"!​

:beerchug:
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,611
Members
452,931
Latest member
The Monk

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