Don't know if I did the minor editing right, but did read on code tags. So reposted based on 2 comments from 6StringJazzer. The Application.Run was something I thought required, seen somewhere in a book and did add End Sub which did not get copied over. But with both changes, still get the compile error, Sub not defined
Group: Have two worksheets in same workbook. First worksheet is "ReArrangedAddr" Which basically has a command button to click to run a "Sub" behind the second worksheet "Orig SH Register". When I click on button on first worksheet, I get error "Compile Error: Sub or Function not defined"
* * * * * code behind command button * * * * *
Public Sub ReArrangeButton_Click() ---- this line is in yellow after trying to run
Call RearrangeAddresses ---- this line is in blue
End Sub
* * * * * * *
Code for Sub attempting to be called by command button
' For __________ , 140708, Rearrange address elements in shareholder register
Public iRow As Integer
Public jColumn As Integer
Sub RearrangeAddresses()
Option Explicit
Dim i As Integer, StartRow As Integer
Dim LastAddrElement As Integer
StartRow = ReArrangedAddr!(B4)
i = StartRow
LastAddrElement = Cells(Rows.Count, 1).End(xlUp).Row
iRow = ReArrangedAddr!(B6)
jColumn = 1
Do Until i > LastAddrElement
If IsEmpty(Cells(i, 1)) Then
i = i + 1
Else: ReArrangedAddr!(iRow, jColumn) = Cell(i, 1)
i = i + 1
jColumn = jColumn + 1
ReArrangedAddr!(iRow, jColumn) = Cell(i, 1)
End If
End Sub
Bookmarks