lilmisspink07
New Member
- Joined
- Aug 17, 2011
- Messages
- 4
Hello,
Hopefully someone can help me with this as it has been driving me nuts!
I am writing a macro to format a file. The number of rows can change and also, there may not always be data in every cell so I need to make sure this is covered in the macro.
I have this little extract that I use earlier when auto-filling to ensure I get all the rows:
' Dynamic autofill success counts for all samples
LastRow = Range("A65536").End(xlUp).Row
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
Now in a later part, I need to find a cell in the header row, then select the column down to the last row and perform a find and replace. I can't figure out how to get my LastRow variable into the selected range though?
This is where it needs to go....
' GTtoAC on DQ381153 & highlight pink
Cells.Find(What:="DQ381153", After:=Range("A1"), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="T", Replacement:="A", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="G", Replacement:="C", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
With Selection.Interior
.ColorIndex = 38
.Pattern = xlSolid
End With
I'm guessing that LastRow needs to go somewhere in the red bit but I'm new to VB and struggling to figure it out!!
Thanks in advance!
Hopefully someone can help me with this as it has been driving me nuts!
I am writing a macro to format a file. The number of rows can change and also, there may not always be data in every cell so I need to make sure this is covered in the macro.
I have this little extract that I use earlier when auto-filling to ensure I get all the rows:
' Dynamic autofill success counts for all samples
LastRow = Range("A65536").End(xlUp).Row
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B" & LastRow), Type:=xlFillDefault
Now in a later part, I need to find a cell in the header row, then select the column down to the last row and perform a find and replace. I can't figure out how to get my LastRow variable into the selected range though?
This is where it needs to go....
' GTtoAC on DQ381153 & highlight pink
Cells.Find(What:="DQ381153", After:=Range("A1"), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="T", Replacement:="A", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="G", Replacement:="C", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
With Selection.Interior
.ColorIndex = 38
.Pattern = xlSolid
End With
I'm guessing that LastRow needs to go somewhere in the red bit but I'm new to VB and struggling to figure it out!!
Thanks in advance!