Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find row and insert formula, skipping columns
Hello ... I need some help building code to find a specified row and
insert a formula in every other column. The sheet is set up like this: Column C holds the value to be matched against Column E is the first column to add the first formula, and then in every other column out to Col BY (so E/G/I/etc). The value to match will be hard-coded into the code itself ... Any/all help is greatly appreciated... Regards, ray |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find row and insert formula, skipping columns
Try something like this:
Private Sub TestMatching() Dim sValue As String, dX As Double, dY As Double sValue = "Text to find a match for" 'hardcoded thing you're wanting to match. I'm assuming it's a string, but you can change it to a number type if you want. 'loop through all populated rows in column C For dX = 1 To ActiveSheet.UsedRange.Rows.Count If Cells(dX, 3).Value = sValue Then 'if a match is found, loop through every other adjacent column and then add the formula For dY = 5 To 78 Step 2 Cells(dX, dY).Formula = "=C" & dX 'this formula equals the value in column C. Change the formula to whatever you need. Next End If Next MsgBox "All done" End Sub On Oct 30, 8:22 am, Ray wrote: Hello ... I need some help building code to find a specified row and insert a formula in every other column. The sheet is set up like this: Column C holds the value to be matched against Column E is the first column to add the first formula, and then in every other column out to Col BY (so E/G/I/etc). The value to match will be hard-coded into the code itself ... Any/all help is greatly appreciated... Regards, ray |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sum skipping columns | Excel Discussion (Misc queries) | |||
Summing across columns while skipping some columns | Excel Worksheet Functions | |||
Skipping Columns | Excel Programming | |||
skipping columns part 2 | Excel Worksheet Functions | |||
skipping columns | Excel Worksheet Functions |