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 8956443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:47:18+00:00 2026-06-15T14:47:18+00:00

I wrote a code in vbscript as below ,but when i run my script

  • 0

I wrote a code in vbscript as below ,but when i run my script it is giving an error saying the “Range” is undefined. Can any help me here by saying what is the error?

For TaskCounter = 1 to 35    
  TaskRangeFrom="Task"&TaskCounter&" Start Date"    
  TaskRangeTo="Task"&(TaskCounter+1)&" Name"    
  objSheet6.Range(Range(TaskRangeFrom).Offset(,1), _ 
  Range(TaskRangeTo).Offset(,-1)).EntireColumn.Delete
Next 

Thanks in advance.

  • 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-06-15T14:47:18+00:00Added an answer on June 15, 2026 at 2:47 pm

    As @NickSlash mentioned yesterday, I doubt that you have given range names like
    “Business Process ID” (containg spaces) to your columns. But as this may be
    a version thing, I show you how to get a ‘whole column’ range object for a
    column named “TaskB” (via the “define name” dialog):

    ' Range by Name
    Set oRng = oWs.Range("TaskB")
    

    To get a range for the second column by (column) number, use:

    ' Range by Number
    Set oRng = oWs.Cells(1, 2).EntireColumn
    

    Please note: row and column numbers start with 1. So your “.Offset(,1)”
    code looks very fishy; it may have caused the “Unknown runtime error”.

    If you – as I suppose – wrote your column titles in the first row, you’ll
    have to loop over the columns of that row and check the values:

    ' Range by Lookup
    Set oRng = Nothing
    For nCol = 1 To 5
        If "Title B" = oWs.Cells(1, nCol).Value Then
           Set oRng = oWs.Cells(1, nCol).EntireColumn
           Exit For
        End If
    Next
    

    If you want to experiment, insert those snippets into test code like:

    Dim oFS    : Set oFS = CreateObject("Scripting.FileSystemObject")
    Dim sDir   : sDir    = oFS.GetAbsolutePathname("..\xls")
    Dim sFSpec : sFSpec  = oFS.BuildPath(sDir, "work.xls")
    ' Start clean
    oFS.CopyFile oFS.BuildPath(sDir, "13763603.xls"), sFSpec
    
    ' Open .XLS
    Dim oXls : Set oXls = CreateObject("Excel.Application")
    Dim oWb  : Set oWb  = oXls.Workbooks.Open(sFSpec)
    Dim oWs  : Set oWs  = oWb.Worksheets(1)
    Dim oRng, nCol
    
    ' Range by XXX
    ...
    
    oXls.Visible = True
    WScript.Stdin.ReadLine
    If Not oRng Is Nothing Then
       oRng.Delete
       WScript.Stdin.ReadLine
    End If
    oXls.Visible = False
    oWb.Close False
    oXls.Quit
    

    Pics to give evidence:

    Before

    After

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

Sidebar

Related Questions

Basic doubt...If QTP generates vbscript code as we record actions, can't we directly write
I wrote code to get name of printer which is installed in my system.but
I wrote this code for zoom in/out . it works but even with one
How I can solve this error message Microsoft VBScript runtime error '800a01a8' Object required:
Is there a macro, VBA code or VBScript that I can write to edit
I have below condition in my C# 2.0. There is some VbScript code: For
I want to convert below SQL Server code to VBScript in classic ASP... DECLARE
Can VBA code be written to perform actions on any Excel file? When I
I am having below code in VBScript ' Retrieve the keyword category for page
I was having below code in VbScript for checking the valid navigation Item. '==============================================

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.