[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

excel and vba easy question for pro

Posted on 2003-11-13
9
Medium Priority
?
250 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 405 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

Hire Technology Freelancers with Gigs

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 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