Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default What am I doing wrong?

I have a Sheet(form) that I am trying to Populate (row by
row) using a UserForm. The problem is that the area to be
populated is in the middle of the sheet (i.e A21:AD52).

I have created range names for the columns and even
created a range name to define the range (A21:AD52), but
alas, my code is not working. Please help

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) + 1

'Transfer the data to the sheet
Range("Release_PN") = TextPN.Text
Range("Release_Description") = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21") = "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What am I doing wrong?

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) ' remove +1 since offset is zero based

'Transfer the data to the sheet
Range("Release_PN")(1).Offset(NextRow,0) = TextPN.Text
Range("Release_Description")(1).Offset(NextRow,0) = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21") = "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub

--
Regards,
Tom Ogilvy

"John Petty" wrote in message
...
I have a Sheet(form) that I am trying to Populate (row by
row) using a UserForm. The problem is that the area to be
populated is in the middle of the sheet (i.e A21:AD52).

I have created range names for the columns and even
created a range name to define the range (A21:AD52), but
alas, my code is not working. Please help

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) + 1

'Transfer the data to the sheet
Range("Release_PN") = TextPN.Text
Range("Release_Description") = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21") = "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default What am I doing wrong?

Tom,

Thanks for the help. It definitely loads the data into
the cells, but it is not dropping done to the next row
after loading in fresh data to the form. It just
overwrites the existing data. Any ideas?
-----Original Message-----
Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) ' remove +1 since offset is zero based

'Transfer the data to the sheet
Range("Release_PN")(1).Offset(NextRow,0) = TextPN.Text
Range("Release_Description")(1).Offset(NextRow,0) =

TextDescription.Text
If CheckAccessory.Value = True Then Range("D21") = "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub

--
Regards,
Tom Ogilvy

"John Petty" wrote in message
...
I have a Sheet(form) that I am trying to Populate (row

by
row) using a UserForm. The problem is that the area to

be
populated is in the middle of the sheet (i.e A21:AD52).

I have created range names for the columns and even
created a range name to define the range (A21:AD52), but
alas, my code is not working. Please help

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) + 1

'Transfer the data to the sheet
Range("Release_PN") = TextPN.Text
Range("Release_Description") = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21")

= "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What am I doing wrong?

Thanks again Tom. My mistake, I forgot to tag the Range
("ReleaseAction") in my data transfer so it always saw
that field as open.

Thanks again.
-----Original Message-----
Tom,

Thanks for the help. It definitely loads the data into
the cells, but it is not dropping done to the next row
after loading in fresh data to the form. It just
overwrites the existing data. Any ideas?
-----Original Message-----
Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) ' remove +1 since offset is zero

based

'Transfer the data to the sheet
Range("Release_PN")(1).Offset(NextRow,0) =

TextPN.Text
Range("Release_Description")(1).Offset(NextRow,0) =

TextDescription.Text
If CheckAccessory.Value = True Then Range("D21")

= "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub

--
Regards,
Tom Ogilvy

"John Petty" wrote in message
...
I have a Sheet(form) that I am trying to Populate (row

by
row) using a UserForm. The problem is that the area

to
be
populated is in the middle of the sheet (i.e A21:AD52).

I have created range names for the columns and even
created a range name to define the range (A21:AD52),

but
alas, my code is not working. Please help

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) + 1

'Transfer the data to the sheet
Range("Release_PN") = TextPN.Text
Range("Release_Description") = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21")

= "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub



.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What am I doing wrong?

Your basing your nextRow value on the range ReleaseAction - but your code
doesn't show you writing anything to that range. It appears your post
didn't include all your code, but it should work if you are writing a value
each time in ReleaseAction. You could change the alogrithm to

cnt = Range("Release_PN").count
nextRow = Range("Release_PN").Offset(cnt,0).Resize(1).End(xl up).Row
if nextRow < Range("Release_PN")(1).Row then
nextRow = 0
else
nextRow = NextRow - Range("Release_PN")(0).row
End if

Or use

Application.WorksheetFunction.CountA(Range _
("Release_PN"))

--
Regards,
Tom Ogilvy


"John Petty" wrote in message
...
Tom,

Thanks for the help. It definitely loads the data into
the cells, but it is not dropping done to the next row
after loading in fresh data to the form. It just
overwrites the existing data. Any ideas?
-----Original Message-----
Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) ' remove +1 since offset is zero based

'Transfer the data to the sheet
Range("Release_PN")(1).Offset(NextRow,0) = TextPN.Text
Range("Release_Description")(1).Offset(NextRow,0) =

TextDescription.Text
If CheckAccessory.Value = True Then Range("D21") = "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub

--
Regards,
Tom Ogilvy

"John Petty" wrote in message
...
I have a Sheet(form) that I am trying to Populate (row

by
row) using a UserForm. The problem is that the area to

be
populated is in the middle of the sheet (i.e A21:AD52).

I have created range names for the columns and even
created a range name to define the range (A21:AD52), but
alas, my code is not working. Please help

Private Sub CommandNext_Click()
Dim NextRow As Integer
On Error Resume Next

'Make sure that the Release form is Active
Sheets("Release").Activate

' Determine the next Empty Row
NextRow = _
Application.WorksheetFunction.CountA(Range _
("ReleaseAction")) + 1

'Transfer the data to the sheet
Range("Release_PN") = TextPN.Text
Range("Release_Description") = TextDescription.Text
If CheckAccessory.Value = True Then Range("D21")

= "X"
(and the rest of the data)

' Reset the Userform for the next row
TextPN.Text = ""
TextDescription.Text = ""
CheckAccessory.Value = False
End Sub



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong in this Eqn? Raz Excel Worksheet Functions 1 January 12th 10 07:27 PM
What am I doing wrong aussiegirlone Excel Discussion (Misc queries) 15 July 18th 09 10:08 AM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Getting wrong value due to ref? jesmin Excel Discussion (Misc queries) 2 March 16th 06 02:12 AM
What am I doing wrong? Jeff Excel Discussion (Misc queries) 6 March 6th 05 03:01 AM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"