Solved

excel and vba easy question for pro

Posted on 2003-11-13
9
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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