Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Offset problem

After Dave helped me clean up my code last night I thought I was good to go.
/sigh I have a userform which needs to input data into next available blank
row in database. Code is below. The Select Case stuff offsets, but the
other stuff doesn't. What am I doing wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng
i = 1
For Each ctrl In Me.Controls
If TypeOf ctrl Is msForms.TextBox Then
Rng(0, i).Value = ctrl.Value
i = i + 1
End If
Next ctrl
Select Case True
Case optA.Value
Rng.Offset(0, 57).Value = "A"
Case optB.Value
Rng.Offset(0, 57).Value = "B"
End Select

End With
End With

Robbyn
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Offset problem

modify

Rng(0, i).Value = ctrl.Value

to

Rng.offset(0, i).Value = ctrl.Value

HTH

"Robbyn" wrote:

After Dave helped me clean up my code last night I thought I was good to go.
/sigh I have a userform which needs to input data into next available blank
row in database. Code is below. The Select Case stuff offsets, but the
other stuff doesn't. What am I doing wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng
i = 1
For Each ctrl In Me.Controls
If TypeOf ctrl Is msForms.TextBox Then
Rng(0, i).Value = ctrl.Value
i = i + 1
End If
Next ctrl
Select Case True
Case optA.Value
Rng.Offset(0, 57).Value = "A"
Case optB.Value
Rng.Offset(0, 57).Value = "B"
End Select

End With
End With

Robbyn

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Offset problem

Hi Jim,

Your suggestion didn't work (it moved the data over to the next column,
instead of the next row) BUT you gave me an idea and I tried

Rng(1, i).Value = ctrl.Value

and it worked. No idea why, but I'm grateful. Thanks for your quick
response.

"Jim Thomlinson" wrote:

modify

Rng(0, i).Value = ctrl.Value

to

Rng.offset(0, i).Value = ctrl.Value

HTH

"Robbyn" wrote:

After Dave helped me clean up my code last night I thought I was good to go.
/sigh I have a userform which needs to input data into next available blank
row in database. Code is below. The Select Case stuff offsets, but the
other stuff doesn't. What am I doing wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng
i = 1
For Each ctrl In Me.Controls
If TypeOf ctrl Is msForms.TextBox Then
Rng(0, i).Value = ctrl.Value
i = i + 1
End If
Next ctrl
Select Case True
Case optA.Value
Rng.Offset(0, 57).Value = "A"
Case optB.Value
Rng.Offset(0, 57).Value = "B"
End Select

End With
End With

Robbyn

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
OFFSET problem alan82 Excel Worksheet Functions 4 November 20th 08 02:55 AM
Offset Problem Dawn Excel Discussion (Misc queries) 4 June 11th 08 06:44 PM
OFFSET PROBLEM txm49 Excel Discussion (Misc queries) 2 October 11th 07 08:15 PM
Offset VBA Problem jlclyde Excel Discussion (Misc queries) 3 September 18th 07 04:00 PM
Offset Problem morrida3 New Users to Excel 1 September 16th 05 08:02 PM


All times are GMT +1. The time now is 03:01 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"