Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default 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
Reply
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
divide column(x) by column(y) to give column(x/y) in excel? James New Users to Excel 2 April 24th 23 11:46 AM
how do I do subtractions in excel ladyace New Users to Excel 2 August 7th 07 07:24 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
Compare lists for additions and subtractions John Michl Excel Worksheet Functions 2 June 2nd 06 04:30 PM
Divide Column A by Column B multiply Column C Stumped Excel Worksheet Functions 3 December 28th 05 05:51 AM


All times are GMT +1. The time now is 08:42 AM.

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"