Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:13:35+00:00 2026-05-20T10:13:35+00:00

In a program that I’m trying to write now I take two columns of

  • 0

In a program that I’m trying to write now I take two columns of numbers and perform calculations on them. I don’t know where these two columns are located until the user tells me (they input the column value in a cell in the workbook that my code is located in).

For example, if the user inputted “A” and “B” as the columns where all the information is in I can perform calculations based on those values. Likewise if they wanted to analyze another worksheet (or workbook) and the columns are in “F” and “G” they could input those. The problem is that I’m asking the user to input those two columns as well as four others (the last four are the result columns). I did this in hopes that I would be able to make this flexible, but now inflexibility is acceptable.

My question is, if I’m given a value of where some information will be (let’s say “F”) how can I figure out what the column will be after or before that inputted value. So if I’m only given “F” I’ll be able to create a variable to hold the “G” column.

Below are examples of how the variables worked before I needed to do this new problem:

Dim first_Column As String
Dim second_Column As String
Dim third_Column As String

first_Column = Range("B2").Text
second_Column = Range("B3").Text
third_Column = Range("B4").Text

Here the cells B2 – B4 are where the user inputs the values. Generally I want to be able to not have the B3 and B4 anymore. I feel like the Offset(0,1) might be able to help somehow but so far I’ve been unable to implement it correctly.

Thank you,

Jesse Smothermon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:13:35+00:00Added an answer on May 20, 2026 at 10:13 am

    Here are two functions that will help you dealing with columns > “Z”. They convert the textual form of a column to a column index (as a Long value) and vice versa:

    Function ColTextToInt(ByVal col As String) As Long
        Dim c1 As String, c2 As String
        col = UCase(col) 'Make sure we are dealing with "A", not with "a"
        If Len(col) = 1 Then  'if "A" to "Z" is given, there is just one letter to decode
            ColTextToInt = Asc(col) - Asc("A") + 1
        ElseIf Len(col) = 2 Then
            c1 = Left(col, 1)  ' two letter columns: split to left and right letter
            c2 = Right(col, 1)
            ' calculate the column indexes from both letters  
            ColTextToInt = (Asc(c1) - Asc("A") + 1) * 26 + (Asc(c2) - Asc("A") + 1)
        Else
            ColTextToInt = 0
        End If
    End Function
    
    Function ColIntToText(ByVal col As Long) As String
        Dim i1 As Long, i2 As Long
        i1 = (col - 1) \ 26   ' col - 1 =i1*26+i2 : this calculates i1 and i2 from col 
        i2 = (col - 1) Mod 26
        ColIntToText = Chr(Asc("A") + i2)  ' if i1 is 0, this is the column from "A" to "Z"
        If i1 > 0 Then 'in this case, i1 represents the first letter of the two-letter columns
            ColIntToText = Chr(Asc("A") + i1 - 1) & ColIntToText ' add the first letter to the result
        End If
    End Function
    

    Now your problem can be solved easily, for example

    newColumn = ColIntToText(ColTextToInt(oldColumn)+1)
    

    EDITED accordingly to the remark of mwolfe02:

    Of course, if you are not interested in the column names, but just want to get a range object of a specific cell in a given row right beneath a column given by the user, this code is “overkill”. In this case, a simple

     Dim r as Range
     Dim row as long, oldColumn as String
     ' ... init row and oldColumn here ...
    
     Set r = mysheet.Range(oldColumn & row).Offset(0,1)
     ' now use r to manipulate the cell right to the original cell
    

    will do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program that I am writing's purpose arose with this issue: There are two
I have a java program that I am trying to generate 3 outputs for,
I am writing a program that needs to take text input, and modify individual
I made a Java program that runs on a computer with two RS-232 ports.
A program that animates circles is not drawing them fluidly once several hundred are
I have a program that scans an image and converts gems to specific numbers.
I have to write program that counts how many different letters are in string.
I have to write program that create process using pipe() . My first task
The program that I am currently assigned to has a requirement that I copy
A program that I work on assumes that the UUID generated by the Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.