Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Extract a cells format and apply to a variable

I need to extract an activecells format and apply that format to a
variable.
I am using the activecell value and placing it alongside a checkbox as
its text. At a later date I am extracting this text value as a search
parameter. Unfortunately it looses format profile and I can't search
on dates or currency.
If I had the format stored I could condition the variable prior to
using it in a search..... any help appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Extract a cells format and apply to a variable

Mike,

Excel doesn't search on format - it searches on value only.

You don't say where you are pasting the value - into a cell, or into
a textbox or other object.

You can format the cell by copying and using pastespecial formats, and
you can search by using the value of the cell - if you are using a
cell.

If you are using a text box, you can use the Activecell.Text to get a
formatted string to paste into the text box. But then you should
search after using the CDbl function to extract the value from the
formatted text string.

HTH,
Bernie


"MikeR" wrote in message
om...
I need to extract an activecells format and apply that format to a
variable.
I am using the activecell value and placing it alongside a checkbox

as
its text. At a later date I am extracting this text value as a

search
parameter. Unfortunately it looses format profile and I can't search
on dates or currency.
If I had the format stored I could condition the variable prior to
using it in a search..... any help appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Extract a cells format and apply to a variable

Mike,

You'll probably have to assign a variable to each of the many formatting
options. Below is code assigning some of the formatting.

============================================
Code examples to set variables:
HA = Activecell.HorizontalAlignment
FS = Activecell.FontStyle
NF = Activecell.NumberFormat

I think these should be dimmed as String.
============================================

Selection.NumberFormat = "#,##0.00"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.ShrinkToFit = False
.MergeCells = False
End With
With Selection.Font
.Name = "@Batang"
.FontStyle = "Italic"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDashDotDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With

--
sb
"MikeR" wrote in message
om...
I need to extract an activecells format and apply that format to a
variable.
I am using the activecell value and placing it alongside a checkbox as
its text. At a later date I am extracting this text value as a search
parameter. Unfortunately it looses format profile and I can't search
on dates or currency.
If I had the format stored I could condition the variable prior to
using it in a search..... any help appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Extract a cells format and apply to a variable

"steve" wrote in message ...
Mike,

You'll probably have to assign a variable to each of the many formatting
options. Below is code assigning some of the formatting.

============================================
Code examples to set variables:
HA = Activecell.HorizontalAlignment
FS = Activecell.FontStyle
NF = Activecell.NumberFormat


Thanks Bernie,Jim and Steve for your replies.....

Jim gave me the clue I needed....


FormatType = ActiveCell.Offset(1, 0).NumberFormat <-----!!!!!!! this did it

rest of code......

If FormatType < "General" Then
FindMe = Format(Names(j), FormatType)
Else
FindMe = Names(j)
End If

Continue with code.....


I can now use my filter to "find" any format type I am likely to encounter!!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Extract a cells format and apply to a variable

Instead of capturing the ActiveCell's .Value property try getting its .Text
property.

--
Jim Rech
Excel MVP




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract a cells format and apply to a variable

If I'm right in what I think you want to do, you can try using:

*ActiveCell.NumberFormat*

this will give you the format of the current cell. For example a cell
that is formatted as Text will return "@".

General cells will return "General".
Time and Date cells will return the time or date format you selected
etc.

You can format the cells, then run some code to record all the formats
you require.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract a cells format and apply to a variable

If I'm right in what I think you want to do, you can try using:

*ActiveCell.NumberFormat*

this will give you the format of the current cell. For example a cell
that is formatted as Text will return the "@".

General cells will return "General".
Time and Date cells will return the time or date format you selected
etc.

You can format your cells, then run some code to record all the formats
you require.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Extract a cells format and apply to a variable

pini35 wrote in message ...
If I'm right in what I think you want to do, you can try using:

*ActiveCell.NumberFormat*

this will give you the format of the current cell. For example a cell
that is formatted as Text will return the "@".

General cells will return "General".
Time and Date cells will return the time or date format you selected
etc.

You can format your cells, then run some code to record all the formats
you require.


Cheers pini35, that is exactly what I wanted.... just needed the right syntax.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract a number from a variable text string tipsy Excel Discussion (Misc queries) 4 May 4th 08 03:28 AM
Apply format to row if yes response DebbieV Excel Discussion (Misc queries) 2 January 23rd 08 01:51 AM
apply different prices to different quantities (variable pricing?) Raymond Ray Excel Worksheet Functions 3 January 21st 07 08:11 AM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
How to apply a format to an entire workbook Peo Sjoblom Excel Worksheet Functions 0 May 17th 05 06:11 PM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"