ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help using nameranges to write to columns (https://www.excelbanter.com/excel-programming/412067-need-help-using-nameranges-write-columns.html)

IT Junior

Need help using nameranges to write to columns
 
Hi im new to vb and Excel
Im tring to create a form that you can type a value in a text box and it
saves it in a seperate sheet, on a specific column in the workbook

What I have so far is a button and text box, And a name range(scraprng)that
is column q thru row 365


-------------------------------------------------------------------

Private Sub CommandButton1_Click()

Worksheets("OEE Data").Range("scraprng") = scraptxtbox

--------------------------------------------------------------------
say i type a value into the text box and hit the button, it will save the
value in the column , but in all the cells in the namerange

What I want it to do is save the value in only one cell at a time in the
namerange per button click

--
Thanks

JLGWhiz

Need help using nameranges to write to columns
 
You will need to adjust the value of i to match the number of cells in your
named range.

Private Sub CommandButton1_Click()
Dim i As Long
For i = 3 To 16 '<<<This needs to be setbased
'on the cells in named range.
If Worksheets("OEE Data") _
.Cells(i, Range("scraprng").Column) "" Then
Else
Worksheets("OEE Data") _
.Cells(i, Range("scraprng").Column) = scraptxtbox
Exit For
End If
Next
End Sub




"IT Junior" wrote:

Hi im new to vb and Excel
Im tring to create a form that you can type a value in a text box and it
saves it in a seperate sheet, on a specific column in the workbook

What I have so far is a button and text box, And a name range(scraprng)that
is column q thru row 365


-------------------------------------------------------------------

Private Sub CommandButton1_Click()

Worksheets("OEE Data").Range("scraprng") = scraptxtbox

--------------------------------------------------------------------
say i type a value into the text box and hit the button, it will save the
value in the column , but in all the cells in the namerange

What I want it to do is save the value in only one cell at a time in the
namerange per button click

--
Thanks



All times are GMT +1. The time now is 10:30 AM.

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