Solved

excel and vba easy question for pro

Posted on 2003-11-13
9
233 Views
Last Modified: 2010-05-01
This is what i want:

I have an excel sheet and want to insert some product
A form comes up. I fill it and when i click on toevoegen. it must add the stuff in the excel sheet, not override any cell
So cell A1,A2 is filled So first is must check wich A cell is empty and then it must fill it ( it fill the hole row so B and c with the thing i fill in the userform)


to get an idea here is something

Private Sub Toevoegen_Click()

Do Until x = ""


Range(Ax) = TextBox1.Text
Range(Bx) = TextBox2.Text
Range(Cx) = TextBox3.Text
Range(Dx) = TextBox4.Text
Range(Ex) = TextBox5.Text
End Sub
0
Comment
Question by:akari2000
  • 6
  • 3
9 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9739035
That will tell you what is the last cell on the excel sheet


Application.ActiveSheet.Cells(1, 1).SpecialCells(xlCellTypeLastCell).row
Application.ActiveSheet.Cells(1, 1).SpecialCells(xlCellTypeLastCell).column
0
 
LVL 1

Author Comment

by:akari2000
ID: 9739154
Yeah that is a possible solotion. but this is visual basic and i need vba code

In vba if you put some thing in a cell you ro

range("A1") = textbox1.text

so how do i fille it this way
0
 
LVL 1

Author Comment

by:akari2000
ID: 9739188
ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Activate is to activate the last cell that is empty but I want it to look in range A and then return the numberso it can fill the cells in that row
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 135 total points
ID: 9739351
Just do that

dim row

row = Application.ActiveSheet.Cells(1, 1).SpecialCells(xlCellTypeLastCell).row + 1
Range("A" & row) = TextBox1.Text
Range("B" & row) = TextBox2.Text
Range("C" & row) = TextBox3.Text
Range("D" & row) = TextBox4.Text
Range("E" & row) = TextBox5.Text
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:akari2000
ID: 9739475
I had something lik thiss in mind:

x = 1
Range(Ax).Select

    Do
       x = x + 1
       xx = Range(Ax)
    Loop While xx = ""

but it doesn't work because range needs "" between it
Range("A1").select and if i do that i dont know how to use the x
0
 
LVL 1

Author Comment

by:akari2000
ID: 9739525
Ok now i have this

Private Sub Toevoegen_Click()
x = 1
Range("A" & x).Select

    Do
       x = x + 1
       Range("A" & x).Select
       xx = Range("A" & x)
    Loop While xx = ""
   


Range("A" & x) = TextBox1.Text
Range("B" & x) = TextBox2.Text
Range("C" & x) = TextBox3.Text
Range("D" & x) = TextBox4.Text
Range("E" & x) = TextBox5.Text

MsgBox "Het artikel is toegevoegd"
End Sub

It work 1 time if i press toevoegen again it doesn't work
0
 
LVL 1

Author Comment

by:akari2000
ID: 9739591
Yes i have done it (with a little help of you) it was loop until not loop while
0
 
LVL 1

Author Comment

by:akari2000
ID: 9745979
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9747335
>>can you answer this question

You've your answer there
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now