ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find row and insert formula, skipping columns (https://www.excelbanter.com/excel-programming/400254-find-row-insert-formula-skipping-columns.html)

Ray

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


[email protected]

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





All times are GMT +1. The time now is 09:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com