Solved

excel and vba easy question for pro

Posted on 2003-11-13
9
235 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

813 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

8 Experts available now in Live!

Get 1:1 Help Now