how to loop through the data in excel
-
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
-
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
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
-
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
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
-
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
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
-
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
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" -
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"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
-
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
To create a new worksheet you can use:
Sheets.Add