Solved

excel and vba easy question for pro

Posted on 2003-11-13
9
243 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
Industry Leaders: 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

Industry Leaders: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

707 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