Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Inserting Multiple Columns

I have two open worksheets and I'm trying to insert 3 columns into the active
one. I'm using Visual Studio 2005, and excel 2007. I have this so far.
Dim r As Range
Dim r2 As Range
Dim r3 As Range

r = ("A:CQ") <---getting an error, string can't be converted to
range
r(r.Columns.Count - 86).EntireColumn.Insert()

r2 = ("A:CR")
r2(r2.Columns.Count - 87).EntireColumn.Insert()

r3 = ("A:CS")
r3(r3.Columns.Count - 88).EntireColumn.Insert()

Any ideas? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Inserting Multiple Columns

Set r = Range("A:CQ")
__________________________________________________ _______________________

"NewToVB" wrote in message
...
I have two open worksheets and I'm trying to insert 3 columns into the
active
one. I'm using Visual Studio 2005, and excel 2007. I have this so far.
Dim r As Range
Dim r2 As Range
Dim r3 As Range

r = ("A:CQ") <---getting an error, string can't be converted
to
range
r(r.Columns.Count - 86).EntireColumn.Insert()

r2 = ("A:CR")
r2(r2.Columns.Count - 87).EntireColumn.Insert()

r3 = ("A:CS")
r3(r3.Columns.Count - 88).EntireColumn.Insert()

Any ideas? Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Inserting Multiple Columns

Hi there. I tried that and it says "Range is an expression and cannot be
converted to string"

"Vasant Nanavati" wrote:

Set r = Range("A:CQ")
__________________________________________________ _______________________

"NewToVB" wrote in message
...
I have two open worksheets and I'm trying to insert 3 columns into the
active
one. I'm using Visual Studio 2005, and excel 2007. I have this so far.
Dim r As Range
Dim r2 As Range
Dim r3 As Range

r = ("A:CQ") <---getting an error, string can't be converted
to
range
r(r.Columns.Count - 86).EntireColumn.Insert()

r2 = ("A:CR")
r2(r2.Columns.Count - 87).EntireColumn.Insert()

r3 = ("A:CS")
r3(r3.Columns.Count - 88).EntireColumn.Insert()

Any ideas? Thanks!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Inserting Multiple Columns

I don't use Visual Studio so perhaps a different syntax needs to be used.
You may need to fully qualify the range reference:

Set r = Workbooks("xyz.xls").Worksheets("abc").Range("A:CQ ")
__________________________________________________ _______________________


"NewToVB" wrote in message
...
Hi there. I tried that and it says "Range is an expression and cannot be
converted to string"

"Vasant Nanavati" wrote:

Set r = Range("A:CQ")
__________________________________________________ _______________________

"NewToVB" wrote in message
...
I have two open worksheets and I'm trying to insert 3 columns into the
active
one. I'm using Visual Studio 2005, and excel 2007. I have this so
far.
Dim r As Range
Dim r2 As Range
Dim r3 As Range

r = ("A:CQ") <---getting an error, string can't be
converted
to
range
r(r.Columns.Count - 86).EntireColumn.Insert()

r2 = ("A:CR")
r2(r2.Columns.Count - 87).EntireColumn.Insert()

r3 = ("A:CS")
r3(r3.Columns.Count - 88).EntireColumn.Insert()

Any ideas? Thanks!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Inserting Multiple Columns

Yeah I tried that too, but it didnt' work. Well maybe this is a better
idea.... I think I can do a VLOOKUP. Because I have two workbooks both with
one sheet and unique identifiers in column A. I need loop through sheet1,
column A and find the matching id number in sheet 2 and add a new column with
a calculation in it (the difference in column B from the old sheet and new
sheet)... do you know how I would code a VLOOKUP, i'm really not sure at all.
Thanks!

"Vasant Nanavati" wrote:

I don't use Visual Studio so perhaps a different syntax needs to be used.
You may need to fully qualify the range reference:

Set r = Workbooks("xyz.xls").Worksheets("abc").Range("A:CQ ")
__________________________________________________ _______________________


"NewToVB" wrote in message
...
Hi there. I tried that and it says "Range is an expression and cannot be
converted to string"

"Vasant Nanavati" wrote:

Set r = Range("A:CQ")
__________________________________________________ _______________________

"NewToVB" wrote in message
...
I have two open worksheets and I'm trying to insert 3 columns into the
active
one. I'm using Visual Studio 2005, and excel 2007. I have this so
far.
Dim r As Range
Dim r2 As Range
Dim r3 As Range

r = ("A:CQ") <---getting an error, string can't be
converted
to
range
r(r.Columns.Count - 86).EntireColumn.Insert()

r2 = ("A:CR")
r2(r2.Columns.Count - 87).EntireColumn.Insert()

r3 = ("A:CS")
r3(r3.Columns.Count - 88).EntireColumn.Insert()

Any ideas? Thanks!








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
Inserting Columns Across Multiple Worksheets Big_Tater[_2_] Excel Discussion (Misc queries) 4 March 2nd 09 04:50 PM
Inserting columns GARY Excel Discussion (Misc queries) 2 August 13th 08 04:29 PM
inserting new columns CJ Excel Discussion (Misc queries) 5 September 16th 06 07:18 PM
Inserting columns FinChase Excel Programming 5 February 7th 06 12:14 PM
Inserting Columns GJB Excel Worksheet Functions 1 January 20th 05 03:41 AM


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