Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Referring to a column
This may well be a very daft query! I am writing a macro which
analyses data imported to a spreadsheet. The problem is that it is carrying out analysis on all cells in a column. However, I want to follow the progression: 1) Is there a data value in Column A, row X? 2) Use that value to calculate the value for Column P, row X 3) Otherwise, move on to row Y. I've tried If....Then and Do While.... but I don't know how to specify point 1). How do I persuade the programme to see whether Column A, row X is empty or not? Many thanks, Helen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Referring to a column
Helen,
something along these lines should work for the first twenty rows: Sub CheckCol() Dim X as integer For X = 1 to 20 If Cells(1,x).value< "" Then .. Do Your Thang Here .. End If Next X End Sub This will loop 20 times, looking at the the value in Column A, row x each time - Cells(1,x).value - then carrying out whatever action you require. Cheers, Pete. -----Original Message----- This may well be a very daft query! I am writing a macro which analyses data imported to a spreadsheet. The problem is that it is carrying out analysis on all cells in a column. However, I want to follow the progression: 1) Is there a data value in Column A, row X? 2) Use that value to calculate the value for Column P, row X 3) Otherwise, move on to row Y. I've tried If....Then and Do While.... but I don't know how to specify point 1). How do I persuade the programme to see whether Column A, row X is empty or not? Many thanks, Helen . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Referring to a column
One way:
If IsEmpty(Range("A" & X).Value) Then 'calculate PX End If In article , (Helen) wrote: This may well be a very daft query! I am writing a macro which analyses data imported to a spreadsheet. The problem is that it is carrying out analysis on all cells in a column. However, I want to follow the progression: 1) Is there a data value in Column A, row X? 2) Use that value to calculate the value for Column P, row X 3) Otherwise, move on to row Y. I've tried If....Then and Do While.... but I don't know how to specify point 1). How do I persuade the programme to see whether Column A, row X is empty or not? Many thanks, Helen |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Referring to a column
lastRow = Worksheets(“Sheet1”).UsedRange.Row - 1
Worksheets(“Sheet1”).UsedRange.Rows.Count For x = 1 To lastRow If Worksheets(“Sheet1”).Cells(x, 1).Value < “” Then BLAH BLAH BLAH End If Next x Do you get what I'm doing here? - Piku -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Referring to a portion of a column | Excel Discussion (Misc queries) | |||
Referring a cell | Excel Discussion (Misc queries) | |||
Referring to Cells | Excel Discussion (Misc queries) | |||
Referring to a list in one sheet to another column on a different | Excel Discussion (Misc queries) | |||
Referring to a column | Excel Discussion (Misc queries) |