VBA Copy

BoJaNa

New Member
Joined
Aug 22, 2011
Messages
8
Hello, I'm in hell because of this stupped thing. I want copy value from textboxes (UserForm) in to a Sheet. Every value from every textbox must be copyed to cell in that sheet on the next empty cell. For example value from first textbox must be copyed into a sheet in a next empty cell on colomn A and so on. I use this code:

Private Sub copy_Click()

Range("A1").End(xlDown).Offset(1, 0).Value = data.Value
Range("B1").End(xlDown).Offset(1, 0).Value = nomer.Value
........

End Sub

It's ok for first time. Second time was copyed only in A colomn.
Please help me!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You could first start by referencing to the object you want to copy into and of.
Code:
Sheets("sheet1").Range("A1").End(xlDown).Offset(1,0).Value = Me.data.Value
 
Upvote 0
Thank you but this one is exact like mine

If you can please give me more code to try it.
 
Last edited:
Upvote 0
Code:
Private Sub copy_Click()

Worksheets("Sheet1").Range("A1").End(xlDown).Offset(1, 0).Value = Me.data.Value
Worksheets("Sheet1").Range("B1").End(xlDown).Offset(1, 0).Value = Me.nomer.Value
'........

End Sub

What do you mean it's exact like yours?
Do you mean it gives you the same result as before?

Is there any error message popping up?
 
Upvote 0
If you put the column of interest as the tag in each text box.
(i.e. in your example from post#1, data.Tag = "1" and nomer.Tag = "2")
Then you could do all the text boxes at once like.
Code:
For each oneControl in UserForm1.Controls
    With oneControl
        If IsNumeric(.Tag) Then
            ThisWorkbook.Sheets("Sheet1").Cells(1, Val(.Tag)).End(xlDown).Offset(1,0).Value = .Text
        End If
    End With
Next oneControl
 
Upvote 0
Code:
Private Sub copy_Click()

Worksheets("Sheet1").Range("A1").End(xlDown).Offset(1, 0).Value = Me.data.Value
Worksheets("Sheet1").Range("B1").End(xlDown).Offset(1, 0).Value = Me.nomer.Value
'........

End Sub
What do you mean it's exact like yours?
Do you mean it gives you the same result as before?

Is there any error message popping up?
Yes give me the same result. In A column everithing is ok, but in B column copy and paste in one cell.
 
Upvote 0
If you put the column of interest as the tag in each text box.
(i.e. in your example from post#1, data.Tag = "1" and nomer.Tag = "2")
Then you could do all the text boxes at once like.
Code:
For each oneControl in UserForm1.Controls
    With oneControl
        If IsNumeric(.Tag) Then
            ThisWorkbook.Sheets("Sheet1").Cells(1, Val(.Tag)).End(xlDown).Offset(1,0).Value = .Text
        End If
    End With
Next oneControl
This do nothnig :???:
 
Upvote 0
OK, I thing that I need code something like that:

Public Sub save_Click()
Dim c As Range

With Sheets("Opis").Range("B1:B1000")
For Each c In Range
Set c = Range("B1").End(xlDown).Offset(1, 0)
If c.Offset(0, 0).Value = nomer_sd.Value Then
MsgBox "Saved"
Else
MsgBox "Error"
End If
Next c

End With
End Sub

but in this line " For Each c In Range" I have Error "Argument not optional"

If someone can send me correct code would be nice!
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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