ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Range in one macro to range in another (https://www.excelbanter.com/excel-programming/292489-set-range-one-macro-range-another.html)

tim

Set Range in one macro to range in another
 
I currently place well names(B-07 3) in column A by resizing the cell but i realize the size isn't always 279 as in the second macro but is always the size range between y and x or y-x of the first macro. How can i set the second macro resize or paste range of the well the same range size as x and y fron the first macro. Trick

Sub Macro3(

' Macro3 Macr
' Macro recorded 2/24/2004 by Husky Use

Dim z As Rang
Sheets("Eclipse").Selec
Range("A1").Selec
Cells.Find(What:="time", After:=ActiveCell, LookIn:=xlFormulas, LookAt
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=
False).Activat
Cells.Find(What:="days", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
.Selec
Set z = ActiveCel
Cells(z.Row + 2, "B").Selec

x = ActiveCell.Addres
Selection.End(xlDown).Selec
y = ActiveCell.Addres
Range(x, y).Selec
Application.CutCopyMode = Fals
Selection.Cop

Sheets("Sheet1").Selec
Range("B2").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past

Sheets("Sheet2").Selec
Range("B2").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past
cLastRow = Cells(Rows.Count, "B").End(xlUp).Ro
Cells(cLastRow + 1, "B").Selec
ActiveSheet.Past

Sheets("Sheet2").Selec
Columns("B:B").Selec
Selection.NumberFormat = "mm/dd/yy

Sheets("Sheet1").Selec
Columns("B:B").Selec
Selection.NumberFormat = "mm/dd/yy

End Su


Sub Name_Format(

' Name_Format Macr
' Macro recorded 2/24/2004 by Husky Use


Sheets("Sheet2").Selec
Range("A2").Selec
ActiveCell.FormulaR1C1 = "B-07 1
x = Cells(65536, "A").End(xlUp).Ro
Cells(x, "A").Copy Cells(x, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 4
y = Cells(65536, "A").End(xlUp).Ro
Cells(y, "A").Copy Cells(y, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 6
z = Cells(65536, "A").End(xlUp).Ro
Cells(z, "A").Copy Cells(z, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 7
k = Cells(65536, "A").End(xlUp).Ro
Cells(k, "A").Copy Cells(k, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 8
v = Cells(65536, "A").End(xlUp).Ro
Cells(v, "A").Copy Cells(v, "A").Resize(279, 1




Sheets("Sheet1").Selec
Range("A2").Selec
ActiveCell.FormulaR1C1 = "B-07 2
a = Cells(65536, "A").End(xlUp).Ro
Cells(a, "A").Copy Cells(a, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 3
b = Cells(65536, "A").End(xlUp).Ro
Cells(b, "A").Copy Cells(b, "A").Resize(279, 1

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Cells(cLastRow + 1, "A").Value = "B-07 5
c = Cells(65536, "A").End(xlUp).Ro
Cells(c, "A").Copy Cells(c, "A").Resize(279, 1


End Su



All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com