Help with Last Column

Adam88

New Member
Joined
Dec 12, 2017
Messages
16
Hi,

I have a form used for data entry, I would like to save the data from one of the text fields into Row 2 of the first empty column on another worksheet. I've got a handle of how to do this for a row, but I can't quite workout how to change it to suit a column.

Hope you can help, thanks
Adam
 
What is the name of the userform? what is the name of the textbox (assuming at the moment it is txtVendorName)?

and try

Code:
Dim LastColumn as Long
Dim ws As Worksheet
Set ws = Sheet5
LastColumn = ws.Range(2, Columns.Count).End(xlToLeft).Column + 1
[COLOR="#FF0000"]ws.[/COLOR]Cells(2, LastColumn).Value = [COLOR="#FF0000"]YourUserformName.[/COLOR]txtVendorName.Text
.

Changing YourUserformName. to suit.
 
Last edited:
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Carrying out your instructions still seems to result in the same 1004 error, although it now seems to point to;

Code:
LastColumn = ws.Range(2, Columns.Count).End(xlToLeft).Column + 1

as the erroneous code?

Thanks
 
Upvote 0
Range should be Cells which you changed from mumps post :(....

Code:
LastColumn = ws.[COLOR="#FF0000"]Cells[/COLOR](2, Columns.Count).End(xlToLeft).Column + 1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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