Results 1 to 5 of 5

Thread: [RESOLVED] VB2008-How to use "Array" member of excel

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2010
    Posts
    17

    Resolved [RESOLVED] VB2008-How to use "Array" member of excel

    Hi all,

    I am using Visual Basic 2008 to manipulate some data in a spreadsheet. I am having a problem using Excel's built in RemoveDuplicates function. Here is the line of code I need to fix...

    wSheet.Range(strRange).RemoveDuplicates(Columns:=Array(1, 2, 3, 4, 5, 6), Header:=Excel.XlYesNoGuess.xlNo)

    The keyword "Array" is where the issue lies. What is "Array" a member of? I tried the object library but did not find it in there. I can use another method to remove the duplicates but am still curious.

    Thanks!

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: VB2008-How to use "Array" member of excel

    What is the exact error message that you are getting?

    Try this

    Code:
    Dim Columns As Object
    Dim Header As XlYesNoGuess
    Set their values and then try this?

    Code:
    wSheet.Range(strRange).RemoveDuplicates(Columns, Header)
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2010
    Posts
    17

    Re: VB2008-How to use "Array" member of excel

    This does not work. Let me be more specific. I am essentially trying to convert a line of excel vba code to Visual Basic. The code works in Excel vba. Here is the original code with no modifications...

    wSheet.Range(strRange).RemoveDuplicates(Columns:=Array(1, 2, 3, 4, 5, 6), Header:=xlNo)

    Visual Basic does not recognize "Array" or "xlNo". So the error says "xlNo" is not declared and would say "array" is not declared if "array" was not a keyword in Visual Basic(it says "array" is a type and cannot be used as an expression"). I was able to fix the xlNo by using the Excel Library reference, Excel.xlYesNoGuess.xlNo. I got the syntax from the Excel Object Library. However, I need something like Excel.????.Array or something similar to tell Visual Basic the keyword "Array" is coming from the Excel Library.

    Thanks!

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: VB2008-How to use "Array" member of excel

    Try this

    Code:
    wSheet.Range(strRange).RemoveDuplicates( _
    Columns:=New Object() {1, 2, 3, 4, 5, 6}, _
    Header:=Excel.XlYesNoGuess.xlNo)
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2010
    Posts
    17

    Re: VB2008-How to use "Array" member of excel

    Works great, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width