Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default change all specific row references to next row available in fill downformula

Was using this code to fill down each column with formulas in G4:I4.
(Headers in G5:I5)

Need to change because there may be existing data in columns G6:I6
down.

Want to change code to fill down formulas starting at next row
avaialble (G:I)

To sum it all up, I want to change all row 6 references in code to
next row available in that column.

Sub filldowndata()
'
' Macro1 Macro
' Macro recorded 3/17/2009 by FTN

Sheets("data").Select
Range("G4:l4").Select
Selection.Copy
Range("G6").Select
ActiveSheet.Paste

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("f6:f" & .Cells(.Rows.Count, "f").End
(xlUp).Row)
Set rngFormula = .Range("g6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("g6:g" & .Cells(.Rows.Count, "g").End
(xlUp).Row)
Set rngFormula = .Range("h6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("h6:h" & .Cells(.Rows.Count, "h").End
(xlUp).Row)
Set rngFormula = .Range("i6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("i6:i" & .Cells(.Rows.Count, "i").End
(xlUp).Row)
Set rngFormula = .Range("j6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With
With ThisWorkbook.Worksheets("data")
Set rngData = .Range("j6:j" & .Cells(.Rows.Count, "j").End
(xlUp).Row)
Set rngFormula = .Range("k6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With
With ThisWorkbook.Worksheets("data")
Set rngData = .Range("k6:k" & .Cells(.Rows.Count, "k").End
(xlUp).Row)
Set rngFormula = .Range("l6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

Range("G6").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Selection.Cells(1)

'Range("a6").Select
'Range(Selection, Selection.End(xlDown)).Select
Sheets("rollup").Select
Application.Run "AllWorksheetPivots"
Application.Run "Memo1"


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default change all specific row references to next row available in fill down formula

This will copy the formulas in G4:I4 to the bottom of G:I, and then conver the formulas to values

Sub Filldowndata2()
With Sheets("data")
.Range("G4:I4").Copy .Cells(Rows.Count, 7).End(xlUp)(2)
With .Cells(Rows.Count, 7).End(xlUp).Resize(1, 3)
.Value = .Value
End With
End With
End Sub

HTH,
Bernie
MS Excel MVP


"J.W. Aldridge" wrote in message
...
Was using this code to fill down each column with formulas in G4:I4.
(Headers in G5:I5)

Need to change because there may be existing data in columns G6:I6
down.

Want to change code to fill down formulas starting at next row
avaialble (G:I)

To sum it all up, I want to change all row 6 references in code to
next row available in that column.

Sub filldowndata()
'
' Macro1 Macro
' Macro recorded 3/17/2009 by FTN

Sheets("data").Select
Range("G4:l4").Select
Selection.Copy
Range("G6").Select
ActiveSheet.Paste

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("f6:f" & .Cells(.Rows.Count, "f").End
(xlUp).Row)
Set rngFormula = .Range("g6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("g6:g" & .Cells(.Rows.Count, "g").End
(xlUp).Row)
Set rngFormula = .Range("h6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("h6:h" & .Cells(.Rows.Count, "h").End
(xlUp).Row)
Set rngFormula = .Range("i6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

With ThisWorkbook.Worksheets("data")
Set rngData = .Range("i6:i" & .Cells(.Rows.Count, "i").End
(xlUp).Row)
Set rngFormula = .Range("j6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With
With ThisWorkbook.Worksheets("data")
Set rngData = .Range("j6:j" & .Cells(.Rows.Count, "j").End
(xlUp).Row)
Set rngFormula = .Range("k6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With
With ThisWorkbook.Worksheets("data")
Set rngData = .Range("k6:k" & .Cells(.Rows.Count, "k").End
(xlUp).Row)
Set rngFormula = .Range("l6")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row,
rngFormula.Column))
End With

Range("G6").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Selection.Cells(1)

'Range("a6").Select
'Range(Selection, Selection.End(xlDown)).Select
Sheets("rollup").Select
Application.Run "AllWorksheetPivots"
Application.Run "Memo1"


End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default change all specific row references to next row available in filldown formula

thanx!
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 to fill cell references from several worksheets in one? Jenykell Excel Worksheet Functions 2 January 29th 10 11:12 PM
Fill down with references to worksheets [email protected] Excel Worksheet Functions 3 July 10th 08 04:20 PM
Max to specific references Steve Excel Worksheet Functions 5 December 21st 06 07:41 PM
Auto Fill with some references locked [email protected] Excel Discussion (Misc queries) 3 February 28th 06 05:50 PM
Auto fill references claytorm[_14_] Excel Programming 1 October 29th 05 01:03 AM


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