LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Automatic copy of cell formatting between sheets

Hi,

I've got this follow-up question buried in another post (Selective
selecting of multiple tabs), but I felt I should pull it out here as a
seperate post in hopes of getting more views.

I recieved some great help that led to a positive solution (solution
from Jim Cone included below), and I'm hoping to be able to tweak this
macro so that the formatting in the cell on the CTD sheet matches that
of the same cell on the Data Entry sheet. When data gets entered onto
the Data Entry sheet, we set significant figures and cell orientation
(center or right justified). Is there a way for that to get
translated to the CTD tab too? Thanks.

Frank

On Fri, 15 Apr 2011 20:05:33 -0700, "Jim Cone"
wrote:

It is good practice to use Option Explicit and declare all variables.
In worksheet event code "Target" is the active cell.
Qualify all ranges with the parent sheet (and the workbook if there is more than one).
The following code is untested but should be close to what you want...
'---
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myActiveCell As String
Dim myFormula As String

myActiveCell = Target(1).Address(False, False)
myFormula = Sheets("CTD").Range(myActiveCell).FormulaR1C1
If InStr(1, myFormula, "=IF(ISERROR", vbTextCompare) Then
Sheets("Data Entry").Select
Else
Sheets(Array("Data Entry", "CTD")).Select
End If
End Sub
'---
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(Determine Colors (excel add-in) - in the free folder)


on 4/15/2011, Phrank supposed :
Hi,

I've got a workbook with one tab for data entry and the other tab for
data presentation (with imbedded formulas for %differences from
controls and such). Initially, both sheets are identical, but I
sometimes need to insert rows and columns. Rather than doing this
twice, I just select both tabs. The problem is that I (and others)
oftentimes forget to have both tabs selected during modification or
data entry, and we end up having to waste time fixing things. So, I
drafted a quick macro for the Worksheet_SelectionChange event that I
thought would work well, but I've got a snag. It reads the address of
the active cell, then checks the same cell in the 2nd sheet for the
formula. IF the formula starts a certain way (with =IF(ISERRO), then
I want the macro to end. If it doesn't start with that, then I want
the macro to force the selection of the second tab. But, it's failing
when it tries to check the same cell on the 2nd sheet. The macro
seems to work if I try it outside of the event routine, but when I put
it in the Worksheet, it fails. Can anyone give me advice on how to
fix and/or improve this please? Thanks.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
myActiveCell = ActiveCell.Address
Sheets("CTD").Activate
Range(myActiveCell).Activate ' IT'S FAILING RIGHT HERE. WHY?
myFormula = ActiveCell.FormulaR1C1
myStartFormula = Mid(myFormula, 1, 11)
If myStartFormula = "=IF(ISERROR" Then
Sheets("Data Entry").Select
GoTo Line1
Else

Sheets(Array("Data Entry", "CTD")).Select

End If

Line1:
End Sub

 
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
Automatic Sumning of Same Cell from Different Sheets Excel Ella Excel Worksheet Functions 3 April 8th 10 11:36 PM
Grouped sheets page formatting will copy the header James Trujillo Excel Worksheet Functions 3 December 9th 09 01:26 AM
copy cell info to other sheets, other sheets dont contain all row. Ja Excel Worksheet Functions 1 November 1st 09 12:53 AM
How do I copy print formatting to multiple sheets in a workbook? BFB@keystone Excel Discussion (Misc queries) 2 March 29th 06 01:34 AM
Automatic cell formatting Werner[_31_] Excel Programming 1 July 21st 05 02:48 PM


All times are GMT +1. The time now is 01:53 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"