Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to set sheet1!cell = sheet2!samecell and set format?

Hi,

I have a workbook with approx. 50 sheets. I am trying to add a summary sheet
by referencing corresponding cells in the existing sheets.

I seem to be doing ok as far as values are concerned but I can't figure out
how to assign cell formats simply.

As follows;

sub MakeSummary()

ActiveWorkbook.Worksheets.Add befo=ActiveWorkbook.Worksheets(1)
ActiveSheet.Name = "Departments"
ActiveSheet.Range("A1").Activate

For intCell = 1 To endRow

' This bit goes ok! Note: Only referencing a single sheet in this
sample.
strCell = "='" & ActiveWorkbook.Worksheets(2).Name & "'" & "!A" &
intCell
ActiveCell.Formula = strCell
strCell = "A" & intCell

' Next bit doesn't work - Why? Is there a better way?
ActiveCell.Range(strCell).Font.Bold = _
ActiveWorkbook.Worksheets(2).Range(strCell).Font.B old
If ActiveCell.Value = 0 Then
ActiveCell.Value = ""
End If
' Move down 1 cell
ActiveCell.Offset(1, 0).Activate
Next
end sub

Any help much appreciated!

Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How to set sheet1!cell = sheet2!samecell and set format?


-----Original Message-----
Hi,

I have a workbook with approx. 50 sheets. I am trying to

add a summary sheet
by referencing corresponding cells in the existing sheets.

I seem to be doing ok as far as values are concerned but

I can't figure out
how to assign cell formats simply.

As follows;

sub MakeSummary()

ActiveWorkbook.Worksheets.Add

befo=ActiveWorkbook.Worksheets(1)
ActiveSheet.Name = "Departments"
ActiveSheet.Range("A1").Activate

For intCell = 1 To endRow

' This bit goes ok! Note: Only referencing a

single sheet in this
sample.
strCell = "='" & ActiveWorkbook.Worksheets

(2).Name & "'" & "!A" &
intCell
ActiveCell.Formula = strCell
strCell = "A" & intCell

' Next bit doesn't work - Why? Is there a better

way?
ActiveCell.Range(strCell).Font.Bold = _
ActiveWorkbook.Worksheets(2).Range

(strCell).Font.Bold
If ActiveCell.Value = 0 Then
ActiveCell.Value = ""
End If
' Move down 1 cell
ActiveCell.Offset(1, 0).Activate
Next
end sub

Any help much appreciated!

Paul


.
I would use if statements like:


if activeworkbook.sheets(2).range(strCell).font.bold =
true then
activesheet.range(strcell.font.bold= true
else
end if

nath.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default re

If the values you want to summarize is one the same place
on each sheet, you can use the Consolidate function on the
DATA tab..

Gunnar
-----Original Message-----
Hi,

I have a workbook with approx. 50 sheets. I am trying to

add a summary sheet
by referencing corresponding cells in the existing sheets.

I seem to be doing ok as far as values are concerned but

I can't figure out
how to assign cell formats simply.

As follows;

sub MakeSummary()

ActiveWorkbook.Worksheets.Add

befo=ActiveWorkbook.Worksheets(1)
ActiveSheet.Name = "Departments"
ActiveSheet.Range("A1").Activate

For intCell = 1 To endRow

' This bit goes ok! Note: Only referencing a

single sheet in this
sample.
strCell = "='" & ActiveWorkbook.Worksheets

(2).Name & "'" & "!A" &
intCell
ActiveCell.Formula = strCell
strCell = "A" & intCell

' Next bit doesn't work - Why? Is there a better

way?
ActiveCell.Range(strCell).Font.Bold = _
ActiveWorkbook.Worksheets(2).Range

(strCell).Font.Bold
If ActiveCell.Value = 0 Then
ActiveCell.Value = ""
End If
' Move down 1 cell
ActiveCell.Offset(1, 0).Activate
Next
end sub

Any help much appreciated!

Paul


.

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
copy data from sheet2 to sheet1 when sheet2 has variable # of rows Anne Excel Discussion (Misc queries) 6 February 27th 09 09:48 PM
jump to cell in sheet2 when values in sheet1 is true amelia Excel Discussion (Misc queries) 3 January 18th 09 08:13 AM
Click one cell sheet1, display all related recs on sheet2 Ginsu Excel Worksheet Functions 1 December 17th 08 11:46 PM
formula-add 2 numbers of cell a1 and a2 of sheet1 ans-b9in sheet2 Anuja Excel Worksheet Functions 1 September 15th 06 06:52 AM
can i type sheet1 A5 and make it show Sheet2 A6 cell HelpMe Excel Discussion (Misc queries) 1 February 25th 05 01:44 AM


All times are GMT +1. The time now is 11:13 PM.

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

About Us

"It's about Microsoft Excel"