Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Calculate number of rows and apply formula

I am writing an Excel 2002 template and need to reformat text data which is
initially copied into an empty sheet (Imported Data). The number of columns
is constant, but the number of rows will vary.
My second sheet (Converted Data) contains lookups or formulae to manipulate
the text strings. These are all in row 2.

The formulae in 'Converted Data' are copied down manually to match the
number of rows in 'Imported Data', thus converting all of the data.

How can I achieve this automatically using VBA?


If I right click on the 'Converted Data' tab and 'View Code', I assume I can
write the VBA code here ....


Private Sub Worksheet_Activate()
' VBA code
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Calculate number of rows and apply formula

Hi,

I'm not sure putting this in Worksheet_Activate is the right thing to do
because it will execute every time you select the worksheet.

You don't give details of columns or formula so here's a way of entering a
formula and filling down as far as there are data in an adjacent column.

Private Sub Worksheet_Activate()
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("B1").Formula = "=A1"
Range("B1:B" & LastRow).FillDown
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Grey Old Man" wrote:

I am writing an Excel 2002 template and need to reformat text data which is
initially copied into an empty sheet (Imported Data). The number of columns
is constant, but the number of rows will vary.
My second sheet (Converted Data) contains lookups or formulae to manipulate
the text strings. These are all in row 2.

The formulae in 'Converted Data' are copied down manually to match the
number of rows in 'Imported Data', thus converting all of the data.

How can I achieve this automatically using VBA?


If I right click on the 'Converted Data' tab and 'View Code', I assume I can
write the VBA code here ....


Private Sub Worksheet_Activate()
' VBA code
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Calculate number of rows and apply formula

I need to count the rows in a sheet named 'Imported Data' where the column
range is A:R.

The conversion is applied in a sheet named 'Converted Data' where the
formulae are all in row 2.

I need to automatically fill down from 'Converted Data'!A2:R2 until it
reaches the row count of 'Imported Data'


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Calculate number of rows and apply formula

Sub Auto_Fill()
Dim lRow As Long
With Sheets("Converted Data")
lRow = Sheets("Imported Data").Range("A" & Rows.Count).End(xlUp).Row
.Range("A2:R" & lRow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP


On Mon, 15 Mar 2010 06:30:01 -0700, Grey Old Man
wrote:

I need to count the rows in a sheet named 'Imported Data' where the column
range is A:R.

The conversion is applied in a sheet named 'Converted Data' where the
formulae are all in row 2.

I need to automatically fill down from 'Converted Data'!A2:R2 until it
reaches the row count of 'Imported Data'


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Calculate number of rows and apply formula

I eventually solved this with ...

Private Sub Worksheet_Activate()
Dim LastRow As Long
LastRow = Sheet1.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheet2.Range("A2:R" & LastRow).FillDown
End Sub
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
How do I apply a formula to multiple rows at the same time? ManhattanRebel Excel Worksheet Functions 1 November 22nd 07 03:28 PM
setting a formula to apply to all rows in a column dave @ stejonda New Users to Excel 7 January 14th 07 09:09 AM
formula to apply concatenation to successive rows of data Devo Excel Worksheet Functions 2 July 24th 06 05:42 PM
apply formula to other rows ... berti Excel Discussion (Misc queries) 1 December 15th 05 08:30 AM
Apply a simple formula to multiple rows? RedFox New Users to Excel 9 May 9th 05 11:42 PM


All times are GMT +1. The time now is 10:30 AM.

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"