auto fill the last cell of the column with destination range

gkisacik

New Member
Joined
Oct 29, 2018
Messages
24
Hi,

I am trying to create new reference number and add the last empty cell of Column M: How can i fix this code at destination range??

A2018-01
A2018-02
D2018-03
A2018-04
A2018-05
A2018-06
A2018-07
D2018-08
D2018-09
A2018-10
A2018-11
A2018-12
empty cell here (for instance)

i tried to run macro and got the following;

Code:
Range("M1").Select
Selection.End(xlDown).Select
Selection.AutoFill Destination:=Range("M30:M31"), Type:=xlFillDefault
 
In that case use
Code:
Set wsuser = Worksheets("Users")
With[COLOR=#ff0000] wsuser.[/COLOR]Range("M1").End(xlDown)
   .AutoFill Destination:=.Resize(2), Type:=xlFillDefault
End With
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
That worked well, thank you, how can i get the last value on userform.

i tried it frmbrief.txtprojectno.text=activecell.value

it didnt do the right job.

In that case use
Code:
Set wsuser = Worksheets("Users")
With[COLOR=#ff0000] wsuser.[/COLOR]Range("M1").End(xlDown)
   .AutoFill Destination:=.Resize(2), Type:=xlFillDefault
End With
 
Upvote 0
Try
Code:
Private Sub cmdaddnew_Click()

Unload Me
Dim wsuser As Worksheet
frmbrief.txtowner.Text = lbowner.Caption
Set wsuser = Worksheets("data")
With Range("M1").End(xlDown)
   .AutoFill Destination:=.Resize(2), Type:=xlFillDefault
   frmbrief.txtprojectno.Text .Offset(1).Value
End With
End Sub
 
Upvote 0
Brilliant, thank you for this. I added "=" between frmbrief.txtprojectno.text and .offset(1).value.

it works fine now

Try
Code:
Private Sub cmdaddnew_Click()

Unload Me
Dim wsuser As Worksheet
frmbrief.txtowner.Text = lbowner.Caption
Set wsuser = Worksheets("data")
With Range("M1").End(xlDown)
   .AutoFill Destination:=.Resize(2), Type:=xlFillDefault
   frmbrief.txtprojectno.Text .Offset(1).Value
End With
End Sub
 
Upvote 0
Glad it's sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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