Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VB-Copy formula down until adjacent cell (left) is blank?

Here is exactly what I am trying to do through VB in Excel:

Weekly data pull fills colums A:G. Row count is always different. I am
modifying the data pull through VB, and I have a VLOOKUP formula in cell H2.
What I want VB to do is copy that formula down column H to the last row (with
data) each week. I guess I want it to be dynamic so that as rows
decrease/increase the formula is only copied down to the final row/record.

I know someone out of this smart group will know how to do this!

Thanks in advance!

Tony


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Excel VB-Copy formula down until adjacent cell (left) is blank?

Hi,
Try this, hope it works for you.
Sub Macro1()
Range("G1").Select
Selection.End(xlDown).Select
LastRow = ActiveCell.Row
Range("H2").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1:A" & (LastRow - 2)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 0).Range("A1").Select
End Sub

Thanks,

"Tony P." wrote:

Here is exactly what I am trying to do through VB in Excel:

Weekly data pull fills colums A:G. Row count is always different. I am
modifying the data pull through VB, and I have a VLOOKUP formula in cell H2.
What I want VB to do is copy that formula down column H to the last row (with
data) each week. I guess I want it to be dynamic so that as rows
decrease/increase the formula is only copied down to the final row/record.

I know someone out of this smart group will know how to do this!

Thanks in advance!

Tony


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel VB-Copy formula down until adjacent cell (left) is blank?

Hy Tony

You can try this macro

Sub test()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("H2").AutoFill Destination:=.Range("H2:H" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

It will fill the formula in H2 to H last cell in column A


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tony P." <Tony wrote in message ...
Here is exactly what I am trying to do through VB in Excel:

Weekly data pull fills colums A:G. Row count is always different. I am
modifying the data pull through VB, and I have a VLOOKUP formula in cell H2.
What I want VB to do is copy that formula down column H to the last row (with
data) each week. I guess I want it to be dynamic so that as rows
decrease/increase the formula is only copied down to the final row/record.

I know someone out of this smart group will know how to do this!

Thanks in advance!

Tony




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel VB-Copy formula down until adjacent cell (left) is blank

Worked like a charm, David! Thanks!!!!! Have another one for you when you
get a second. Subject will be "Delete Entire Row"

"David" wrote:

Hi,
Try this, hope it works for you.
Sub Macro1()
Range("G1").Select
Selection.End(xlDown).Select
LastRow = ActiveCell.Row
Range("H2").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1:A" & (LastRow - 2)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 0).Range("A1").Select
End Sub

Thanks,

"Tony P." wrote:

Here is exactly what I am trying to do through VB in Excel:

Weekly data pull fills colums A:G. Row count is always different. I am
modifying the data pull through VB, and I have a VLOOKUP formula in cell H2.
What I want VB to do is copy that formula down column H to the last row (with
data) each week. I guess I want it to be dynamic so that as rows
decrease/increase the formula is only copied down to the final row/record.

I know someone out of this smart group will know how to do this!

Thanks in advance!

Tony


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
If value in cell make adjacent blank whatzzup Excel Discussion (Misc queries) 5 October 31st 07 04:01 PM
formula in excel that will highlight a cell that is left blank? Kimo Excel Worksheet Functions 4 July 21st 07 04:16 PM
Excel VB-Copy formula down until adjacent cell (left) is blank? Tony P. Excel Discussion (Misc queries) 1 May 18th 05 06:11 PM
Return value of heading if an adjacent cell in a row is not blank Wil H. Excel Programming 4 April 25th 05 01:25 PM
Copy formula relative to left cell? JayL Excel Programming 3 September 20th 04 02:12 AM


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