hardcoding cell values based target cells

drfumbles

New Member
Joined
Feb 5, 2016
Messages
8
Hey,
I've been coming to this forum for help, so I finally made an account to ask some questions.

I'm writing a vba that will change a column in a set of tables to the values based on the last row of data for each table. The number of tables isn't constant and is generated by different macro.

So far I have:

Private Sub Hardcode_Tables(ByVal Target As Range)

If Intersect(Target, Range("G:G")) Is Nothing Then 'I don't think "G:G" is allowed
Exit Sub
else

'=============pseudo code ============
'if first column = "last string name (this value is only appears once for each table)" & cell to 2 columns to the right is a numeric nonzero value
'copy from top of continuous data down to where logical is true.
'paste values in the same spot
'advance search starting point to stop looking at cells that have been changed to values

end sub

Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I'm getting closer

Private Sub Hardcode_Columns()
Const csLockText As String = "Flush"
Dim rCell As Range
Dim rLookIn As Range


With Worksheets("Stage Fluid")
Set rLookIn = Intersect(.Range("E:E"), .UsedRange)
If Not rLookIn Is Nothing Then
For Each rCell In rLookIn
With rCell
If (.Text = csLockText & isumeric(rCell.Offset(0, 2).Value)) Then .Value = csLockText
End With
Next rCell
End If
End With
End Sub


I'm not doing the numeric test properly. The code won't compile. "Sub or function not defined"
 
Upvote 0
I corrected the spelling. The code compiles but still won't change the target cell. If I remove the "& isnumeric" part then the code will change the target cell.
 
Upvote 0
Maybe this....but it dosn't seem logical to me
Code:
Private Sub Hardcode_Columns()
Const csLockText As String = "Flush"
Dim rCell As Range, rLookIn As Range


With Worksheets("Stage Fluid")
Set rLookIn = Intersect(.Range("E:E"), .UsedRange)
For Each rCell In rLookIn
If rCell.Value = csLockText And IsNumeric(rCell.Offset(0, 2).Value) Then rCell.Value = csLockText
Next rCell
End With
End Sub
 
Upvote 0
I changed the AND and it works. I have to find a way to make it change a the column and rows in the table with references to hardcode now off of the same logical.
Thanks for help
 
Upvote 0
Care to give more detail on this !!!
I have to find a way to make it change a the column and rows in the table with references to hardcode now off of the same logical.
 
Upvote 0
I need to hard code the table at large. The current row and 135 rows above and 4 columns wide. These can not be hardcoded line by line but change after the logical statement is true.
 
Upvote 0
A simple explanation would be better....I can't see your worksheet OR what you are doing with it !!!
Code:
I need to hard code the table at large. The current row and 135 rows above and 4 columns wide. These can not be hardcoded line by line but change after the logical statement is true.
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top