ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   pulling data and formatting (https://www.excelbanter.com/excel-discussion-misc-queries/155309-pulling-data-formatting.html)

[email protected]

pulling data and formatting
 
I was wondering if there is any way to pull both the data and the
formatting when using an if function? Assuming there is not, any help
me with the VBA code to do such? Thanks.


Ron Rosenfeld

pulling data and formatting
 
On Wed, 22 Aug 2007 08:49:53 -0700, wrote:

I was wondering if there is any way to pull both the data and the
formatting when using an if function? Assuming there is not, any help
me with the VBA code to do such? Thanks.


Depending on what you want to do:

===============================
Option Explicit
Sub PrnFmt()
Dim c As Range
For Each c In Selection
Debug.Print c.Text
Next c

For Each c In Selection
With c.Offset(0, 1)
.NumberFormat = c.NumberFormat
.Value = c.Value
End With
Next c
End Sub
===============================

--ron


All times are GMT +1. The time now is 02:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com