Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Fpr Range Command

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Syntax Fpr Range Command

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Fpr Range Command

Thanks for the reply,

I am not getting any errors, except for the results. The only cell
that is modified is when i=1 (TB1.value is placed into column C of the
chosen row right where it is supposed to be). It is as if the code is
not doing the For/Next loop at all. I even tried replacing the
variable rRowToModify with the row number - Same result.

Any Ideas, thoughts, direction or links the might shed some light are
most welcome?

-Minitman


On Tue, 31 Jul 2007 17:02:01 -0700, JLGWhiz
wrote:

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Syntax Fpr Range Command

I tested your code and it worked without problem for me except when not
select Combobox and push CommandButton2 .
I put three Textboxes named TB1, TB2, TB3 , one Combobox named CB1 and two
CommandButtons on Userform1.
My tested code is something like this.

Sub test()
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
With Range("A65536").End(xlUp)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

Sub sub2()
Dim vRowToModify As Long
vRowToModify = CB1.ListIndex + 1
With Range("A" & vRowToModify)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

keizi

"Minitman" wrote in message
...
Thanks for the reply,

I am not getting any errors, except for the results. The only cell
that is modified is when i=1 (TB1.value is placed into column C of the
chosen row right where it is supposed to be). It is as if the code is
not doing the For/Next loop at all. I even tried replacing the
variable rRowToModify with the row number - Same result.

Any Ideas, thoughts, direction or links the might shed some light are
most welcome?

-Minitman


On Tue, 31 Jul 2007 17:02:01 -0700, JLGWhiz
wrote:

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Fpr Range Command

Hey keizi

Thanks for the reply.

Also thanks for the description of your test workbook, I had to many
excess controls and other stuff on my UserForm to give it out as a
sample. Yours will do the job with a much smaller file size.

I could not get your sample to work until I expanded it to include the
ComboBox RowSource loading. Here is what I came up with. It still
shows what the problem is (I was hoping that by simplifying the code
the problem would go away - no such luck)

I set up Sheet1 with a header row in A1:C1, containing these three
headings:

| Textbox 1 | Textbox 2 | Textbox 3 |

And ComandButton1 somewhere (not important where) on the sheet with
this code:

'_________________________________________________ ______________
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
'_________________________________________________ ______________

in the Sheet1 code module.

Next, I setup UserForm1 with a ComboBox called CB1, three TextBoxes
called TB1, TB2 and TB3. Last, I setup the two CommandButtons.
CommandButton1 labeled "Create" and CommandButton2 labeled "Modify"

Placement of these controls is not important.

I Expanded your code to this:

'_________________________________________________ _______________
Option Explicit
Dim i As Integer
Dim wb As Workbook
Dim ws As Worksheet
Dim LastRow As Integer
Dim ListRange As Range
Dim lRowToModify As Long

Private Sub CB1_Change()
'This auto loads the three TextBoxes with the data
'from the chosen item in the CB1 list

i = 0
If Not CB1.ListIndex < 0 Then
If CB1.ListIndex = 0 Then
For i = 1 To 3
Me.Controls("TB" & i).Text = ""
Next i
Else
For i = 1 To 3
Me.Controls("TB" & i).Text = _
CB1.List(CB1.ListIndex, i - 1)
Next i
End If
End If

End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
'This saves the modified record at the bottom of the list as a new
'record. ***WORKING*** '

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
lRowToModify = LastRow + 1
With Range("A" & lRowToModify)
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Sub sub2()
'This is supposed to take the changes to the record_
'shown in CB1 and overwrite that record.
' ***NOT WORKING*** '
'Instead, it overwrites ONLY the first cell in the correct row!
'It acts like it is not going thru the For/Next loop.

lRowToModify = CB1.ListIndex + 1
With ws.Cells(lRowToModify + 1, "A")
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Private Sub UserForm_Initialize()

Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
ws.Activate
LastRow = Range("A65536").End(xlUp).Row
Set ListRange = ws.Range("A2:C" & LastRow)

'This clears the three TextBoxes
For i = 1 To 3
Me.Controls("TB" & i).Value = vbNullString
Next i

'This sets the RowSource for CB!
With CB1
.RowSource = ListRange.Address
.ColumnCount = ListRange.Columns.Count
.ListIndex = 0 '0 selects first record
End With

'This clears the display of CB1
CB1.Value = vbNullString

End Sub
'_________________________________________________ ________

You should be able to paste my expanded code into your test workbook
and see what I am talking about.

The problem is that I can't seem to get the "Modify" button to modify
all three cells in the chosen row, only the first cell.

At first I thought this was a syntax problem, now I'm not so sure.

Any ideas are appreciated

-Minitman


On Wed, 1 Aug 2007 17:08:16 +0900, "kounoike"
wrote:

I tested your code and it worked without problem for me except when not
select Combobox and push CommandButton2 .
I put three Textboxes named TB1, TB2, TB3 , one Combobox named CB1 and two
CommandButtons on Userform1.
My tested code is something like this.

Sub test()
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
With Range("A65536").End(xlUp)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

Sub sub2()
Dim vRowToModify As Long
vRowToModify = CB1.ListIndex + 1
With Range("A" & vRowToModify)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

keizi

"Minitman" wrote in message
.. .
Thanks for the reply,

I am not getting any errors, except for the results. The only cell
that is modified is when i=1 (TB1.value is placed into column C of the
chosen row right where it is supposed to be). It is as if the code is
not doing the For/Next loop at all. I even tried replacing the
variable rRowToModify with the row number - Same result.

Any Ideas, thoughts, direction or links the might shed some light are
most welcome?

-Minitman


On Tue, 31 Jul 2007 17:02:01 -0700, JLGWhiz
wrote:

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Syntax Fpr Range Command

Please Note:

I think this post may have a bad title and a bit confusing body.

I will try a different approach.

Thanks to all who looked at it.

Until later,

-Minitman

On Wed, 01 Aug 2007 14:00:19 -0500, Minitman
wrote:

Hey keizi

Thanks for the reply.

Also thanks for the description of your test workbook, I had to many
excess controls and other stuff on my UserForm to give it out as a
sample. Yours will do the job with a much smaller file size.

I could not get your sample to work until I expanded it to include the
ComboBox RowSource loading. Here is what I came up with. It still
shows what the problem is (I was hoping that by simplifying the code
the problem would go away - no such luck)

I set up Sheet1 with a header row in A1:C1, containing these three
headings:

| Textbox 1 | Textbox 2 | Textbox 3 |

And ComandButton1 somewhere (not important where) on the sheet with
this code:

'________________________________________________ _______________
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
'________________________________________________ _______________

in the Sheet1 code module.

Next, I setup UserForm1 with a ComboBox called CB1, three TextBoxes
called TB1, TB2 and TB3. Last, I setup the two CommandButtons.
CommandButton1 labeled "Create" and CommandButton2 labeled "Modify"

Placement of these controls is not important.

I Expanded your code to this:

'________________________________________________ ________________
Option Explicit
Dim i As Integer
Dim wb As Workbook
Dim ws As Worksheet
Dim LastRow As Integer
Dim ListRange As Range
Dim lRowToModify As Long

Private Sub CB1_Change()
'This auto loads the three TextBoxes with the data
'from the chosen item in the CB1 list

i = 0
If Not CB1.ListIndex < 0 Then
If CB1.ListIndex = 0 Then
For i = 1 To 3
Me.Controls("TB" & i).Text = ""
Next i
Else
For i = 1 To 3
Me.Controls("TB" & i).Text = _
CB1.List(CB1.ListIndex, i - 1)
Next i
End If
End If

End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
'This saves the modified record at the bottom of the list as a new
'record. ***WORKING*** '

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
lRowToModify = LastRow + 1
With Range("A" & lRowToModify)
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Sub sub2()
'This is supposed to take the changes to the record_
'shown in CB1 and overwrite that record.
' ***NOT WORKING*** '
'Instead, it overwrites ONLY the first cell in the correct row!
'It acts like it is not going thru the For/Next loop.

lRowToModify = CB1.ListIndex + 1
With ws.Cells(lRowToModify + 1, "A")
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Private Sub UserForm_Initialize()

Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
ws.Activate
LastRow = Range("A65536").End(xlUp).Row
Set ListRange = ws.Range("A2:C" & LastRow)

'This clears the three TextBoxes
For i = 1 To 3
Me.Controls("TB" & i).Value = vbNullString
Next i

'This sets the RowSource for CB!
With CB1
.RowSource = ListRange.Address
.ColumnCount = ListRange.Columns.Count
.ListIndex = 0 '0 selects first record
End With

'This clears the display of CB1
CB1.Value = vbNullString

End Sub
'________________________________________________ _________

You should be able to paste my expanded code into your test workbook
and see what I am talking about.

The problem is that I can't seem to get the "Modify" button to modify
all three cells in the chosen row, only the first cell.

At first I thought this was a syntax problem, now I'm not so sure.

Any ideas are appreciated

-Minitman


On Wed, 1 Aug 2007 17:08:16 +0900, "kounoike"
wrote:

I tested your code and it worked without problem for me except when not
select Combobox and push CommandButton2 .
I put three Textboxes named TB1, TB2, TB3 , one Combobox named CB1 and two
CommandButtons on Userform1.
My tested code is something like this.

Sub test()
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
With Range("A65536").End(xlUp)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

Sub sub2()
Dim vRowToModify As Long
vRowToModify = CB1.ListIndex + 1
With Range("A" & vRowToModify)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

keizi

"Minitman" wrote in message
. ..
Thanks for the reply,

I am not getting any errors, except for the results. The only cell
that is modified is when i=1 (TB1.value is placed into column C of the
chosen row right where it is supposed to be). It is as if the code is
not doing the For/Next loop at all. I even tried replacing the
variable rRowToModify with the row number - Same result.

Any Ideas, thoughts, direction or links the might shed some light are
most welcome?

-Minitman


On Tue, 31 Jul 2007 17:02:01 -0700, JLGWhiz
wrote:

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Syntax Fpr Range Command

Hi Minitman

In your first post, i didn't well understand what you want to do.
but now i know what you mean.

this is a workaround, but don't know it's right way to go.

add this declaration

Dim modify As Boolean

and change your CB_Change and sub2 like this.
it might be a good way to initialize variable modify to false in
UserForm_Initialize.

Private Sub CB1_Change()
'This auto loads the three TextBoxes with the data
'from the chosen item in the CB1 list
If Not modify Then 'add this line
i = 0
If Not CB1.ListIndex < 0 Then
If CB1.ListIndex = 0 Then
For i = 1 To 3
Me.Controls("TB" & i).Text = ""
Next i
Else
For i = 1 To 3
Me.Controls("TB" & i).Text = _
CB1.List(CB1.ListIndex, i - 1)
Next i
End If
End If
End If 'add this line
End Sub

Sub sub2()
'This is supposed to take the changes to the record_
'shown in CB1 and overwrite that record.
' ***NOT WORKING*** '
'Instead, it overwrites ONLY the first cell in the correct row!
'It acts like it is not going thru the For/Next loop.
modify = True 'add this line
lRowToModify = CB1.ListIndex + 1
With ws.Cells(lRowToModify + 1, "A")
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
modify = False 'add this line
Unload Me
End Sub

keizi

"Minitman" wrote in message
...
Hey keizi

Thanks for the reply.

Also thanks for the description of your test workbook, I had to many
excess controls and other stuff on my UserForm to give it out as a
sample. Yours will do the job with a much smaller file size.

I could not get your sample to work until I expanded it to include the
ComboBox RowSource loading. Here is what I came up with. It still
shows what the problem is (I was hoping that by simplifying the code
the problem would go away - no such luck)

I set up Sheet1 with a header row in A1:C1, containing these three
headings:

| Textbox 1 | Textbox 2 | Textbox 3 |

And ComandButton1 somewhere (not important where) on the sheet with
this code:

'_________________________________________________ ______________
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
'_________________________________________________ ______________

in the Sheet1 code module.

Next, I setup UserForm1 with a ComboBox called CB1, three TextBoxes
called TB1, TB2 and TB3. Last, I setup the two CommandButtons.
CommandButton1 labeled "Create" and CommandButton2 labeled "Modify"

Placement of these controls is not important.

I Expanded your code to this:

'_________________________________________________ _______________
Option Explicit
Dim i As Integer
Dim wb As Workbook
Dim ws As Worksheet
Dim LastRow As Integer
Dim ListRange As Range
Dim lRowToModify As Long

Private Sub CB1_Change()
'This auto loads the three TextBoxes with the data
'from the chosen item in the CB1 list

i = 0
If Not CB1.ListIndex < 0 Then
If CB1.ListIndex = 0 Then
For i = 1 To 3
Me.Controls("TB" & i).Text = ""
Next i
Else
For i = 1 To 3
Me.Controls("TB" & i).Text = _
CB1.List(CB1.ListIndex, i - 1)
Next i
End If
End If

End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
'This saves the modified record at the bottom of the list as a new
'record. ***WORKING*** '

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
lRowToModify = LastRow + 1
With Range("A" & lRowToModify)
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Sub sub2()
'This is supposed to take the changes to the record_
'shown in CB1 and overwrite that record.
' ***NOT WORKING*** '
'Instead, it overwrites ONLY the first cell in the correct row!
'It acts like it is not going thru the For/Next loop.

lRowToModify = CB1.ListIndex + 1
With ws.Cells(lRowToModify + 1, "A")
For i = 1 To 3
.Offset(0, i - 1).Value = _
Me.Controls("TB" & i).Value
Next i
End With
Unload Me

End Sub

Private Sub UserForm_Initialize()

Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
ws.Activate
LastRow = Range("A65536").End(xlUp).Row
Set ListRange = ws.Range("A2:C" & LastRow)

'This clears the three TextBoxes
For i = 1 To 3
Me.Controls("TB" & i).Value = vbNullString
Next i

'This sets the RowSource for CB!
With CB1
.RowSource = ListRange.Address
.ColumnCount = ListRange.Columns.Count
.ListIndex = 0 '0 selects first record
End With

'This clears the display of CB1
CB1.Value = vbNullString

End Sub
'_________________________________________________ ________

You should be able to paste my expanded code into your test workbook
and see what I am talking about.

The problem is that I can't seem to get the "Modify" button to modify
all three cells in the chosen row, only the first cell.

At first I thought this was a syntax problem, now I'm not so sure.

Any ideas are appreciated

-Minitman


On Wed, 1 Aug 2007 17:08:16 +0900, "kounoike"
wrote:

I tested your code and it worked without problem for me except when not
select Combobox and push CommandButton2 .
I put three Textboxes named TB1, TB2, TB3 , one Combobox named CB1 and two
CommandButtons on Userform1.
My tested code is something like this.

Sub test()
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()
sub1
End Sub

Private Sub CommandButton2_Click()
sub2
End Sub

Sub sub1()
With Range("A65536").End(xlUp)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

Sub sub2()
Dim vRowToModify As Long
vRowToModify = CB1.ListIndex + 1
With Range("A" & vRowToModify)
For i = 1 To 3
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With
End Sub

keizi

"Minitman" wrote in message
. ..
Thanks for the reply,

I am not getting any errors, except for the results. The only cell
that is modified is when i=1 (TB1.value is placed into column C of the
chosen row right where it is supposed to be). It is as if the code is
not doing the For/Next loop at all. I even tried replacing the
variable rRowToModify with the row number - Same result.

Any Ideas, thoughts, direction or links the might shed some light are
most welcome?

-Minitman


On Tue, 31 Jul 2007 17:02:01 -0700, JLGWhiz
wrote:

Are you getting an error message, and if so, what is it?

"Minitman" wrote:

Greetings,

I have two subs to put data from some TextBoxes (TB1 thru TB34) on a
UserForm onto a row on a sheet.

The first sub places the data in the first empty row - this one works.
Here is the code:

With Range("A65536").End(xlUp)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The other sub is supposed to overwrite the row chosen from a ComboBox.
These two subs are identical except for the choice of which row to put
the data into.
Here is the second sub:

vRowToModify = CB1.ListIndex + 1

With Range("A" & vRowToModify)
For i = 1 To 34
.Offset(0, i).Value = _
Me.Controls("TB" & i).Value
Next i
End With

The variable vRowToModify does return the correct row number but I'm
not sure how to use it. the Range statement is not right and that is
messing up the sub

Can someone help me with the syntax of this "With" statement? Nothing
I have tried works.

Any help is greatly appreciated,

-Minitman




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
If syntax to test if command button exists mikeburg[_36_] Excel Programming 1 September 30th 05 01:48 AM
EXCEL command or syntax PCOR Excel Programming 4 March 11th 05 10:01 PM
Syntax for Excel variable using a SQL Select/From/Where Command... Chip Pearson Excel Programming 0 September 8th 04 11:15 PM
Command text syntax and comma Dave Excel Programming 1 July 30th 04 07:47 PM
Correct syntax for use Replace command via DDE? Bjørn Holm Excel Programming 4 November 27th 03 01:07 PM


All times are GMT +1. The time now is 11:43 PM.

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

About Us

"It's about Microsoft Excel"