LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default modify existing macro

Howdie all.
A colleague of mine came in two weeks ago to obtain a macro that input
numbers that iterated, and offset rows.
I want something comparable, but instead the rows for my workbook are
merged. I've tried a few things to modify his code but Im either missing
something or have just missed it entirely. It works great on single, unmerged
rows.
Code for existing macro below. My problem/comments beneath that.
-------------------------------------

Private Sub OKbtn1_Click()
'Dim startno As Long
Dim iRow As Long
Dim StartCell As Range

'some validation???
If IsNumeric(Me.TextBox1.value) = False _
Or IsNumeric(Me.TextBox2.value) = False Then
MsgBox "Non-numbers in textboxes!"
Exit Sub
End If

If CLng(Me.TextBox1.value) = CLng(Me.TextBox2.value) Then
MsgBox "Numbers not in right order!"
Exit Sub
End If

Set StartCell = ActiveCell

For iRow = CLng(Me.TextBox1.value) To CLng(Me.TextBox2.value)
StartCell.value = iRow
Set StartCell = StartCell.Offset(4, 0)
'iRow = StartCell.Offset(4, 0)

' it's my opinion that the problem exists within this for loop.
' If I place the irow=startcell.offset() it causes a semi-infinite loop
until it reaches
' the end of the worksheet- 1048576 rows down.
'I also tried changing startcell to activecell. That did not work.

Next iRow


' ActiveCell.Offset(1, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
' ActiveCell.Offset(4, 0).Activate
' Selection.ClearContents
'

'Range("N2").Activate
End


End Sub
----------------------------------------------

When I go to use this on a four merged row cell it only inputs the value for
the first merged row set. It's like there's no offset activity to continue
inputting numeric values to the last number from my second spinbox.
If I uncomment the clearcontents functions, it offsets, but just to clear
the values that would've been placed there-- if it was working correctly.
My goal is to have it input the values to my predetermined end point from my
user form.
If this isn't cleear enough, I apologize, please let me know.

Thank you.
SteveB
 
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
Help!! To modify existing formula housinglad Excel Discussion (Misc queries) 2 February 11th 10 09:18 PM
Modify the existing formula wilchong via OfficeKB.com New Users to Excel 3 December 16th 08 11:02 AM
Need to Modify Existing Code Ryan Hess Excel Programming 3 August 3rd 07 07:42 PM
Modify an existing Cell formula using VBA Matt[_2_] Excel Discussion (Misc queries) 2 June 11th 07 08:50 PM
Help modify simple existing code?? ali Excel Programming 7 December 30th 03 11:03 PM


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

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"