If value is 12 then fill range 1-12 etc..

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
Unsure best way to do this.

Value in Range A1

If value is 12 then fill 1-12 starting at C1

Then if Range A1 is 6
Do nothing as 6 is already in the filled range

Then if Range A1 changes to 21
Extend fill range to 21

Appreciate any help
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Address(0, 0) = "A1" Then
        If Target.Value > Range("C" & Rows.Count).End(xlUp).Row Then
            With Range("C1")
                .Value = 1
                .DataSeries xlColumns, xlLinear, , 1, Target.Value
            End With
        End If
    End If
End Sub
 
Upvote 0
@Fluff

Thanks for this
I don't need it on worksheet change as it will be called from command button, but I should be able to modify this
 
Upvote 0
OK, any problems adjusting it, just shout.
 
Upvote 0
I don't need it on worksheet change as it will be called from command button, but I should be able to modify this
This macro should do what you want...
Code:
Sub EnterNumberSeries()
  [C1].Resize([A1]) = Evaluate("ROW(1:" & [A1] & ")")
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top