Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Paste to variable number of rows

This will put the Mid formula in column B from row 2 to the last used row in
column A. For example, if you have part numbers in column A from row 2 to
row 45 it will put the formula in B2:B45.

Sub test()

Dim last_row As Long

last_row = Range("A" & Rows.Count).End(xlUp).Row
Sheet1.Range("B2:B" & last_row).FormulaR1C1 = "=MID(RC[-1],4,99)"

End Sub

hth,

Doug

"brook6" wrote in message
...
I have a spreadsheet of part numbers where number of rows will vary month

to month. Each month, I need to extract 2 digits from the part number and
store in another column for some other analysis. I use MID function to do
the extraction.

I have been entering the formula in the top cell of a blank column and

then copying it to the remaining rows. How do I get a macro to do this?
When I used 'macro recorder', it picked up the exact cell range for this
month's spreadsheet...which means it could crash next month if number of
rows is different.



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 down with variable number of rows mohavv Excel Discussion (Misc queries) 5 November 15th 07 04:18 PM
Linking to a Variable Number of Rows - XP/07 RFJ Excel Worksheet Functions 4 May 17th 07 07:53 PM
How to copy&paste a variable range rows and colums IK Excel Discussion (Misc queries) 1 August 30th 06 12:06 AM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM
deleting variable number of rows Nick Excel Programming 1 October 29th 03 04:31 PM


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