Click to See Complete Forum and Search --> : selecting a certain cell in excel


rawdude
April 10th, 2001, 02:14 PM
Hi all,
I am working on a project that is using the VB in Excel. I am trying to figure out how to select a certain cell. Basically, I have a column of numbers and these numbers start at 21 then go down to about 3 and then climb back to 21. They are in one column and consist of 4,120 rows. I have an inputted value, say 13, I need to search though the column of numbers and select the first cell that is just before the cell that is <= 13. Then I need to use that row number to identify where the data should start being used for calculation i.e. delete all data above that row indicator. An suggestions would be greatly appreciatted.

Iouri
April 10th, 2001, 02:20 PM
Set a reference to the Excel Object Library in Project-References.

This will loop through all cells 10 rows by 10 columns of the active worksheet.

Dim oApp As Excel.Application
Dim oSheet As Excel.Worksheet
Dim iRow As Integer
Dim iCol As Integer
Set oApp = GetObject(, "Excel.Application")

Set oSheet = oApp.ActiveSheet
For iRow = 1 To 10
For iCol = 1 To 10
Debug.Print oSheet.Cells(iRow, iCol)
'here you can compare your values with your condition and find the row
'and col
Next iCol
Next iRow

Set oSheet = Nothing
Set oApp = Nothing




Iouri Boutchkine
iouri@hotsheet.com

Iouri
April 10th, 2001, 02:21 PM
Delete the range

Dim xlApp as new Excel.Application
Dim xlWorkbook as Excel.Workbook
Dim xlSheet as Excel.Worksheet
Dim xlRange as Excel.Range

xlApp.Visible = true

set xlWorkbook = xlApp.Workbooks.Add

set xlSheet = xlWorkbook.Sheets(1)

xlSheet.Cells(9, 4) = "Hello"

set xlRange = xlSheet.UsedRange.Find(What:="Hello")

If Not xlRange is nothing then
xlRange.Delete Shift:=xlUp
End If

xlWorkbook.Close false

xlApp.Quit



Iouri Boutchkine
iouri@hotsheet.com