Column subtractions
Option Explicit
Sub testme()
Dim NewColumn As String
Dim NewColNum As Long
Dim TestRng As Range
NewColumn = InputBox("New Column", "New Column for Trends")
Set TestRng = Nothing
On Error Resume Next
Set TestRng = Worksheets(1).Cells(1, NewColumn)
On Error GoTo 0
If TestRng Is Nothing Then
MsgBox "That's not a valid column"
Exit Sub
End If
NewColNum = TestRng.Column
'then you could use NewColNum-1 to be the column to the right.
With ActiveSheet
MsgBox .Range("A1", .Cells(99, NewColNum - 1)).Address(0, 0)
End With
End Sub
If you use .cells(x,y), the y portion represents the column. And excel's VBA
will allow you to use either a string or a number as that argument.
Mike Darrington wrote:
I have an input box that asks the user to input a new column for a range to
set the print area. I have on sheet that has one less column than the rest.
Is there a way to have it take off on column?
Here is what I have
newcolumn = InputBox("New Column", "New Column for Trends")
User puts in AJ
On one sheet I only want it to go to AI is there a way to do this without
asking another question?
--
Dave Peterson
|