Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Drag cell from A1 : A (Value here)

Hello, suppose I have in cell B1 with the value of "x" can anyone suggest me
a macro which would drag cell A1 (A1 has a formula) until A"x"?

I need a macro to drag down formulas, but the problem is have is the
following:

I've recorded a Macro, and for example the moment when I recorded it, I had
at that time 30 rows, so it records the following marcro:

Private Sub CommandButton1_Click()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:A30").Select
Selection.FillDown
End Sub

And if next time I have just 15 it drags until 30 and so on, how can I
manage to have the value in this case of "30" to be taken from a value in
cell B1??

thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Drag cell from A1 : A (Value here)

Maybe...

Private Sub CommandButton1_Click()
Dim LastRow as long

With me
LastRow = .range("B1").value
Range("a1:A" & LastRow).filldown
End with
End Sub

Not too much validation, though.

Ed wrote:

Hello, suppose I have in cell B1 with the value of "x" can anyone suggest me
a macro which would drag cell A1 (A1 has a formula) until A"x"?

I need a macro to drag down formulas, but the problem is have is the
following:

I've recorded a Macro, and for example the moment when I recorded it, I had
at that time 30 rows, so it records the following marcro:

Private Sub CommandButton1_Click()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:A30").Select
Selection.FillDown
End Sub

And if next time I have just 15 it drags until 30 and so on, how can I
manage to have the value in this case of "30" to be taken from a value in
cell B1??

thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Drag cell from A1 : A (Value here)

Hello Dave and thanks for your answer, another doubt came into my mind, maybe
you can help me with it, how can I do the same but for Columns instead of
rows?? And with a keyboard shortcut rather than a button?

thanks

"Dave Peterson" wrote:

Maybe...

Private Sub CommandButton1_Click()
Dim LastRow as long

With me
LastRow = .range("B1").value
Range("a1:A" & LastRow).filldown
End with
End Sub

Not too much validation, though.

Ed wrote:

Hello, suppose I have in cell B1 with the value of "x" can anyone suggest me
a macro which would drag cell A1 (A1 has a formula) until A"x"?

I need a macro to drag down formulas, but the problem is have is the
following:

I've recorded a Macro, and for example the moment when I recorded it, I had
at that time 30 rows, so it records the following marcro:

Private Sub CommandButton1_Click()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:A30").Select
Selection.FillDown
End Sub

And if next time I have just 15 it drags until 30 and so on, how can I
manage to have the value in this case of "30" to be taken from a value in
cell B1??

thanks!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Drag cell from A1 : A (Value here)

Put this in a general module:

Option Explicit
Sub testme()
Dim LastCol As Long
With ActiveSheet
LastCol = .Range("a2").Value
Range("a1", .Cells(1, LastCol)).FillRight
End With
End Sub

Then back to excel
tools|macro|macros...
select the macro
then click options and assign it the shortcut combo of your choice.

Ed wrote:

Hello Dave and thanks for your answer, another doubt came into my mind, maybe
you can help me with it, how can I do the same but for Columns instead of
rows?? And with a keyboard shortcut rather than a button?

thanks

"Dave Peterson" wrote:

Maybe...

Private Sub CommandButton1_Click()
Dim LastRow as long

With me
LastRow = .range("B1").value
Range("a1:A" & LastRow).filldown
End with
End Sub

Not too much validation, though.

Ed wrote:

Hello, suppose I have in cell B1 with the value of "x" can anyone suggest me
a macro which would drag cell A1 (A1 has a formula) until A"x"?

I need a macro to drag down formulas, but the problem is have is the
following:

I've recorded a Macro, and for example the moment when I recorded it, I had
at that time 30 rows, so it records the following marcro:

Private Sub CommandButton1_Click()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:A30").Select
Selection.FillDown
End Sub

And if next time I have just 15 it drags until 30 and so on, how can I
manage to have the value in this case of "30" to be taken from a value in
cell B1??

thanks!


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Drag cell from A1 : A (Value here)

Thankyou very much Dave!

"Dave Peterson" wrote:

Put this in a general module:

Option Explicit
Sub testme()
Dim LastCol As Long
With ActiveSheet
LastCol = .Range("a2").Value
Range("a1", .Cells(1, LastCol)).FillRight
End With
End Sub

Then back to excel
tools|macro|macros...
select the macro
then click options and assign it the shortcut combo of your choice.

Ed wrote:

Hello Dave and thanks for your answer, another doubt came into my mind, maybe
you can help me with it, how can I do the same but for Columns instead of
rows?? And with a keyboard shortcut rather than a button?

thanks

"Dave Peterson" wrote:

Maybe...

Private Sub CommandButton1_Click()
Dim LastRow as long

With me
LastRow = .range("B1").value
Range("a1:A" & LastRow).filldown
End with
End Sub

Not too much validation, though.

Ed wrote:

Hello, suppose I have in cell B1 with the value of "x" can anyone suggest me
a macro which would drag cell A1 (A1 has a formula) until A"x"?

I need a macro to drag down formulas, but the problem is have is the
following:

I've recorded a Macro, and for example the moment when I recorded it, I had
at that time 30 rows, so it records the following marcro:

Private Sub CommandButton1_Click()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:A30").Select
Selection.FillDown
End Sub

And if next time I have just 15 it drags until 30 and so on, how can I
manage to have the value in this case of "30" to be taken from a value in
cell B1??

thanks!

--

Dave Peterson


--

Dave Peterson

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
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
how can I drag formulas with other cell references Bram Excel Discussion (Misc queries) 1 October 10th 05 12:29 PM
Copy an Drag cell Formula Problem Nat Excel Discussion (Misc queries) 1 June 20th 05 03:24 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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