Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Function to store last row and use in autofill selection


I need some help with vba. I'm pretty new to vba and trying to learn.

I currently import a chart to an excel spreadsheet everyday. This chart
generally contains more rows every day and need to find a way to find
the last row on column b and use that into an autofill.

Here's what currently goes on...

Sheets("ST Raw Data").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "=MID(RC[1],5,2)"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A430"),
Type:=xlFillDefault
Range("A2:A430").Select
Sheets("EF Raw Data").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "=MID(RC[1],5,2)"
Selection.AutoFill Destination:=Range("A2:A50"),
Type:=xlFillDefault
Range("A2:A50").Select

A430 and A50 are the current constants I'd like to replace with
variables stored in a function.

Your help appreciated.

Thanks


--
wayliff
------------------------------------------------------------------------
wayliff's Profile: http://www.excelforum.com/member.php...o&userid=29860
View this thread: http://www.excelforum.com/showthread...hreadid=495616

  #2   Report Post  
Posted to microsoft.public.excel.programming
jtp jtp is offline
external usenet poster
 
Posts: 1
Default Function to store last row and use in autofill selection


Give this a shot.

Dim lastrow as Integer

Sheets("ST Raw Data").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "=MID(RC[1],5,2)"

'This will find the last non-empty row
lastrow = Activsheet.Range("B2").End(xlDown).Row
Range("A2").AutoFill Destination:=Range("A2:A" & lastrow),
Type:=xlFillDefault

Do the same with the "EF Raw Data" sheet. Good luck


--
jtp
------------------------------------------------------------------------
jtp's Profile: http://www.excelforum.com/member.php...o&userid=21132
View this thread: http://www.excelforum.com/showthread...hreadid=495616

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Function to store last row and use in autofill selection


Thank you so much...that really did the trick.
I actually made a slight modification to your suggestion to avoi
modifying another line...it worked very well

--
waylif
-----------------------------------------------------------------------
wayliff's Profile: http://www.excelforum.com/member.php...fo&userid=2986
View this thread: http://www.excelforum.com/showthread.php?threadid=49561

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
Selection AutoFill, Excel 2000 & 2003 James Cooper Excel Worksheet Functions 1 January 28th 07 07:51 AM
store inventory sheet(ex:sports equipment store) vardan Excel Worksheet Functions 1 October 11th 06 12:51 AM
Using the autofill function but increment by certain number in function rishid Excel Worksheet Functions 1 July 14th 05 07:40 PM
Autofill Function PGalla06[_9_] Excel Programming 1 June 23rd 05 08:23 PM


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