Return Format

HWL

Active Member
Joined
Dec 1, 2009
Messages
462
Is there a simple one-liner code to return that format of a cell (using VBA)
Like?
range.("b2").format

I'd like to be able to return the color code and the text-type (such as value, text, general)

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Take a look at the CellFormat object in the VBA helpfile.

There's also the CELL function for worksheets.

HTH,
 
Upvote 0
There are several properties that may be of interest

.NumberFormat

.Interior.ColorIndex

.Interior.Color

.TintAndShade

.Font.ColorIndex

and so on.
 
Upvote 0
There are several properties that may be of interest

.NumberFormat

.Interior.ColorIndex

.Interior.Color

.TintAndShade

.Font.ColorIndex

and so on.

These are good thanks! Is there a .format prop? (not numberformat) and perhaps a place I can see all the possible cell formats as a list like you have here with these few?
 
Upvote 0
This VBA code will copy only the Format of A1 to B1.
Code:
Sub TestFormat()
    Range("A1").Copy
    Range("B1").PasteSpecial Paste:=xlPasteFormats
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Workbook ref

Okay this one is annoying.

I have a call to another macro but I can't seem to reference a workbook in the second macro.

In the first macro I have:
Set Newbook = Workbooks.Add
ThisWorkbook.Sheets(1).Range("R18") = Newbook.Name


In the second macro I have:
Set Newbook = Workbooks(ThisWorkbook.Sheets(1).Range("R18"))

What am I doing wrong that I can refer to this new workbook in the second macro?
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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