Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default beginner ColumnsQuestion b + 1 = c how?

Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how do
I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the columns
have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default beginner ColumnsQuestion b + 1 = c how?

you can use "offset" to move rows OR columns

activecell.offset(rows,columns).select

activecell.offset(0,1).select would move one column over.
<you wouldn't have to use .select, i just used it as an example.
susan


Paul Isaak wrote:
Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how do
I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the columns
have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default beginner ColumnsQuestion b + 1 = c how?

This goes down column C and fills the first 10 cells with one more than the
value in column B:

Sub comedy_is_tough()
For i = 1 To 10
Cells(i, "C").Value = Cells(i, "B").Value + 1
Next
End Sub
--
Gary's Student


"Paul Isaak" wrote:

Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how do
I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the columns
have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default beginner ColumnsQuestion b + 1 = c how?

You can use the ascii code to increment Letters


Chr(Asc("A") + 1)

returns "B"




~Steve


Paul Isaak wrote:
Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how do
I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the columns
have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default beginner ColumnsQuestion b + 1 = c how?

Hi,

I think it would be much easier if you turn into "matrix" notation. For
example, instead of referring to cells like this: "A1", refer to them like
this .Cells(1,1). This way you can `sum' columns. Otherwise, you could design
a function that maps letters to columns using the fact that every char has
its correspondign representation in ASCII code. For example, in one
application I used the following code to build cell formulas (like $A$1
+$A209, $B$1 +$B209, etc.).

Option Explicit
Public Function FirmToLetter(Firm As Long)
If Firm = 1 Then
FirmToLetter = Chr(66)
ElseIf 2 <= Firm And Firm < 19 Then
FirmToLetter = Chr(72 + Firm)
ElseIf 19 <= Firm And Firm < 45 Then
FirmToLetter = "A" & Chr(46 + Firm)
ElseIf 45 <= Firm And Firm < 71 Then
FirmToLetter = "B" & Chr(20 + Firm)
ElseIf 71 <= Firm And Firm < 97 Then
FirmToLetter = "C" & Chr(-6 + Firm)
ElseIf 97 <= Firm And Firm < 123 Then
FirmToLetter = "D" & Chr(-32 + Firm)
ElseIf 123 <= Firm And Firm < 149 Then
FirmToLetter = "E" & Chr(-58 + Firm)
ElseIf 149 <= Firm And Firm < 175 Then
FirmToLetter = "F" & Chr(-84 + Firm)
ElseIf 175 <= Firm And Firm < 201 Then
FirmToLetter = "G" & Chr(-110 + Firm)
ElseIf 201 <= Firm And Firm < 227 Then
FirmToLetter = "H" & Chr(-136 + Firm)
ElseIf 227 <= Firm And Firm < 249 Then
FirmToLetter = "I" & Chr(-162 + Firm)
Else
Call MsgBox("That number of firms exceeds Excel's number of columns!")
Exit Function
End If
End Function


--
Carlos


"Paul Isaak" wrote:

Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how do
I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the columns
have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default beginner ColumnsQuestion b + 1 = c how?

Wow

Thanks for all the quick help on that!

Steve's answer made the most sense for my application, but I'll look at the
others to see if I can figure out the advantages of each.

I'm doing something like...

myColumn = "A"
for x = 1 to 50
if range(myColumn,1).value = "some date" then
do whatever
end if
myColumn = Chr(Asc(myColumn) + 1)
next x

I know it's a basic script, but I'm just starting to learn


Thanks again

Paul

--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com



Toll Free - 1-877-852-4590
"Paul Isaak" wrote in message
news:pTI4h.285349$5R2.278674@pd7urf3no...
Forgive me, I'm very new to VBA for Excel

I want to use a for next loop to cycle through data in columns, but how
do I add one to the current column?

IE

A + 1 = B


I was pretty proud of myself when I made it work with rows, but the
columns have me stumped.

Paul
--
__________________________________

The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com







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
I'm an excel beginner please help DLL Excel Worksheet Functions 4 June 29th 09 02:35 AM
VB beginner Matthew Balch Excel Programming 4 August 31st 06 04:31 PM
Please help a beginner.... Lindsey Excel Programming 2 November 25th 05 04:11 PM
Beginner needs help, Look inside! pops-1 Excel Programming 1 September 7th 05 09:37 PM
Beginner at VBA Bob Simon Excel Programming 5 December 4th 04 03:31 PM


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