English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I would like to create a macro loop in Excel, so that I don't have to constantly change a program line with the description of a new item. I have setup small macros in the past, to automate my spreadsheet. If I have a column of items say from cell A1TO A100, and want to do a carry for each one to my criteria, and then carry the results to a specific location, what would the exact program lines be. I know it is an (if then, else combination), also a (goto statement involved) but I need a specific example, as I have had not much luck setting up this macro. I would appreciate anyone's help concerning this matter

Thank You

2007-04-13 01:45:42 · 4 answers · asked by coolcatcanada 1 in Computers & Internet Software

4 answers

The text of the macro would be

For Count = 1 to 100
If Cells(Count,1) = Criteria then Cells(Count,2) = Result
Next Count

2007-04-13 07:06:49 · answer #1 · answered by Dilip Rao 3 · 1 0

Sub Example()

Range("a1").Select

For L = 1 To 100
If ActiveCell.Offset(L, 0) = "your criteria" Then _
ActiveCell.Offset(L, 4) = ActiveCell.Offset(L, 0)

Next

End Sub

2007-04-16 05:08:39 · answer #2 · answered by Anonymous · 0 0

for i = 1 to 100
if cell("A" & i)=whateveryour criteria is then
cell("D" & i)=whatever you want put in there
end if
next i

(you don't need a goto)

2007-04-13 01:56:00 · answer #3 · answered by The Capn 3 · 0 1

You'd want to use a for loop. Start with this:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim firstRow, lastRow, curRow as integer

firstRow = inputBox("Enter the first row")
lastRow = inputBox("Enter the last row")

For curRow = firstRow to lastRow

Next curRow

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Then put your actions in between the For and the Next statements.

2007-04-16 14:11:28 · answer #4 · answered by Lowa 5 · 0 0

fedest.com, questions and answers