I wrote some vba code for a co-worker yesterday. The Excel workbook consists of 8 sheets, minimally formatted with two labels and a vba textbox at the top. There are 100 rows and six columns that are visible (not hidden). There are only three columns with formulas in them and all return a Nullstring unless there is data in one of three columns. As for the VBA code, I inserted a module and wrote a sub to populate the vba textbox at the top of each sheet and, upon calculation of the active sheet, make a call to that sub in the midule. With very little data in the workbook, the file size is close to 34 Mb. Can anyone help me shrink this thing down?
Here is the sub I wrote:
Sub FillText()
Dim i As Integer
Dim x As String
i = 1
' column m = indicator of last row (amount)
ActiveSheet.Range("m1").Select
' If no data on sheet, populate txtbox w/ starting balance
If ActiveCell.Value = "1" Then
If ActiveSheet.Name <> "SCMR" Then
ActiveSheet.txtBal.Text = "$" & Cells(1, 11).Value
Else
ActiveSheet.TextBox1.Text = "$" & Cells(1, 11).Value
End If
Else
' find row w/ last amount
Do Until ActiveCell.Value = "1"
Cells(i, 13).Select
x = Cells(i, 11).Value
i = i + 1
Loop
' populate txtbox w/ last amount
If ActiveSheet.Name <> "SCMR" Then
ActiveSheet.txtBal.Text = "$" & x
Else
Worksheets(6).TextBox1.Text = "$" & x
End If
'go to 1st cell of next row
Cells(i, 1).Select
End If
End Sub
Here is the sub I wrote:
Sub FillText()
Dim i As Integer
Dim x As String
i = 1
' column m = indicator of last row (amount)
ActiveSheet.Range("m1").Select
' If no data on sheet, populate txtbox w/ starting balance
If ActiveCell.Value = "1" Then
If ActiveSheet.Name <> "SCMR" Then
ActiveSheet.txtBal.Text = "$" & Cells(1, 11).Value
Else
ActiveSheet.TextBox1.Text = "$" & Cells(1, 11).Value
End If
Else
' find row w/ last amount
Do Until ActiveCell.Value = "1"
Cells(i, 13).Select
x = Cells(i, 11).Value
i = i + 1
Loop
' populate txtbox w/ last amount
If ActiveSheet.Name <> "SCMR" Then
ActiveSheet.txtBal.Text = "$" & x
Else
Worksheets(6).TextBox1.Text = "$" & x
End If
'go to 1st cell of next row
Cells(i, 1).Select
End If
End Sub