Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to loop through the data in excel

how to loop through the data in excel

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veon cheng
    wrote on last edited by
    #1

    hi all pls help I haved used a VLOOKUP to select the field i require, however i need to select all fields that appear in this column and put them in a table. VLOOKUP will only selects the first cell in the column where this data appears. How can i get it to loop round all of them? veon

    D 1 Reply Last reply
    0
    • V veon cheng

      hi all pls help I haved used a VLOOKUP to select the field i require, however i need to select all fields that appear in this column and put them in a table. VLOOKUP will only selects the first cell in the column where this data appears. How can i get it to loop round all of them? veon

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Use the following code as a starting point ...

      totalrows = ActiveSheet.UsedRange.Rows.Count

      For i = 1 To totalrows

      MsgBox(Sheets("Sheet1").Cells(i, 6))

      Next i

      V 1 Reply Last reply
      0
      • D David Mujica

        Use the following code as a starting point ...

        totalrows = ActiveSheet.UsedRange.Rows.Count

        For i = 1 To totalrows

        MsgBox(Sheets("Sheet1").Cells(i, 6))

        Next i

        V Offline
        V Offline
        veon cheng
        wrote on last edited by
        #3

        hi thanks a lot for the help is there anyway to copy the data in sheet1 to a new spreadsheet. hmm its like using a code to create a new spreadsheet and generate the data from sheet1 to it. but it only generate selected column not all column is it possible to do it in excel 2000 thanks veon

        H D 2 Replies Last reply
        0
        • V veon cheng

          hi thanks a lot for the help is there anyway to copy the data in sheet1 to a new spreadsheet. hmm its like using a code to create a new spreadsheet and generate the data from sheet1 to it. but it only generate selected column not all column is it possible to do it in excel 2000 thanks veon

          H Offline
          H Offline
          helelark123
          wrote on last edited by
          #4

          You need to modify a little, the code snippet that David Mujica gave you Something like that: totalrows = ActiveSheet.UsedRange.Rows.Count For i = 1 To totalrows 'MsgBox(Sheets("Sheet1").Cells(i, 6)) Sheets("Sheet2").Cells(i, 6)=Sheets("Sheet1").Cells(i, 6) 'or whatever Next i

          Shay Noy

          1 Reply Last reply
          0
          • V veon cheng

            hi thanks a lot for the help is there anyway to copy the data in sheet1 to a new spreadsheet. hmm its like using a code to create a new spreadsheet and generate the data from sheet1 to it. but it only generate selected column not all column is it possible to do it in excel 2000 thanks veon

            D Offline
            D Offline
            David Mujica
            wrote on last edited by
            #5

            Here is a code snipet to create a new workbook from VBA.

            Dim Wk As Workbook

            Set Wk = Workbooks.Add
            Application.DisplayAlerts = False
            Wk.SaveAs Filename:="C:\Temp\demosheet.xls"

            V 1 Reply Last reply
            0
            • D David Mujica

              Here is a code snipet to create a new workbook from VBA.

              Dim Wk As Workbook

              Set Wk = Workbooks.Add
              Application.DisplayAlerts = False
              Wk.SaveAs Filename:="C:\Temp\demosheet.xls"

              V Offline
              V Offline
              veon cheng
              wrote on last edited by
              #6

              hi thanks again my dear friends =) can i check with you again the code u given me is to create a new workbook or a new spreadsheet. cause i just need a new spreadsheet will do. thanks =)) veon

              D 1 Reply Last reply
              0
              • V veon cheng

                hi thanks again my dear friends =) can i check with you again the code u given me is to create a new workbook or a new spreadsheet. cause i just need a new spreadsheet will do. thanks =)) veon

                D Offline
                D Offline
                David Mujica
                wrote on last edited by
                #7

                To create a new worksheet you can use:

                Sheets.Add

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups