LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default This clever code ain't doing nothin, why?

If the procedure is in the worksheet module, then the Me keyword is fine. The
problem is that you used both RowIndex and RowNdx (instead of just one of them).

And if your account numbers aren't Longs, you may have other trouble.

The modified version of your code worked fine for me--as long as it was placed
in the worksheet module:

Option Explicit
Public Sub plugAccountNumber()

Dim accountNumber As Variant
Dim startRow As Long
Dim endRow As Long
Dim rowNdx As Long

Application.ScreenUpdating = False
On Error GoTo EndMacro:

' Just doing 50 as a test

startRow = 1
endRow = 50

For rowNdx = startRow To endRow

If Me.Cells(rowNdx, 1).Value < "" Then
accountNumber = Me.Cells(rowNdx, 1).Value
Else
Me.Cells(rowNdx, 1).Value = accountNumber
End If

Next rowNdx

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True

End Sub
Private Sub CommandButton1_Click()
Call plugAccountNumber
End Sub

=======
ps.

Debra Dalgleish has some other code that you may want to review:
http://contextures.com/xlDataEntry02.html#FillProg

Jim08 wrote:

I have a spreadsheet that has the account number in the first collum of the
parent row followed by some children rows that have no account number. I want
to load the spreadsheet into an access database and normalize it but I need
to load the account number into the children rows. So I tried the code below,
it however does nothing. Any help is apprecaited
Thanks
Jim
'
' Plug account number into mailbox records
'
Public Sub plugAccountNumber()

Dim accountNumber As Long
Dim startRow As Long
Dim endRow As Long
Dim rowNdx As Long

Application.ScreenUpdating = False
On Error GoTo EndMacro:

' Just doing 50 as a test

startRow = 1
endRow = 50

For rowNdx = startRow To endRow

If Me.Cells(rowNdx, 1).Value < "" Then
accountNumber = Me.Cells(rowIndex, 1).Value
Else
Me.Cells(rowIndex, 1).Value = accountNumber
End If

Next rowNdx

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True

End Sub


--

Dave Peterson
 
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
sorting clever formula driller Excel Worksheet Functions 0 May 24th 08 12:06 PM
Any (clever) way to automate ROW:COL in copy/paste??? Zilla[_2_] Excel Worksheet Functions 7 March 26th 07 02:30 AM
I need a clever VLOOKUP formula JMB Excel Worksheet Functions 6 December 21st 06 04:04 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
trying to be clever Little pete Excel Programming 1 May 23rd 05 09:34 PM


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