Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
copy paste values macro
Hello
This is my macro Range("K4").Select ActiveCell.FormulaR1C1 = _ "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE))" Range("K4").Select Selection.AutoFill Destination:=Range("K4:K7282") Range("K4:K7282").Select Columns("K:K").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K3").Select End Sub I get the results I want but ...This is a macro that I have to run everyday. So the auto fill range will be different every day . How do I correct the macro? thanks |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
copy paste values macro
Try the below which will auto adjust depending on the number or rows in
Column J Sub MyMacro() Dim lngRow As Long lngRow = Cells(Rows.Count, "J").End(xlUp).Row Range("K4:K" & lngRow).Formula = _ "=IF(ISERROR(VLOOKUP($J4,Sheet2!$A$1:$B$56,2,FALSE ))," & _ """"",VLOOKUP($J4,Sheet2!$A$1:$B$56,2,FALSE))" Range("K4:K" & lngRow).Value = Range("K4:K" & lngRow).Value End Sub If this post helps click Yes --------------- Jacob Skaria "Wanna Learn" wrote: Hello This is my macro Range("K4").Select ActiveCell.FormulaR1C1 = _ "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE))" Range("K4").Select Selection.AutoFill Destination:=Range("K4:K7282") Range("K4:K7282").Select Columns("K:K").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K3").Select End Sub I get the results I want but ...This is a macro that I have to run everyday. So the auto fill range will be different every day . How do I correct the macro? thanks |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
copy paste values macro
If you are willing to select the range:
Selection ="=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FAL SE)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE)) " Selection = Selection.Value will replace the entire macro. If you are not we will need to know how you know how far down to fill the data. -- If this helps, please click the Yes button. Cheers, Shane Devenshire "Wanna Learn" wrote: Hello This is my macro Range("K4").Select ActiveCell.FormulaR1C1 = _ "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE))" Range("K4").Select Selection.AutoFill Destination:=Range("K4:K7282") Range("K4:K7282").Select Columns("K:K").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K3").Select End Sub I get the results I want but ...This is a macro that I have to run everyday. So the auto fill range will be different every day . How do I correct the macro? thanks |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
copy paste values macro
Can you pick out a column that can be used to determine the last used row (how
far to fill the formulas)?? I used column A: Option Explicit Sub testme() Dim LastRow As Long Dim myRng As Range With ActiveSheet LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row Set myRng = .Range("K4", .Cells(LastRow, "K")) With myRng .FormulaR1C1 _ = "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E))," _ & """"",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE)) " .Value = .Value End With End With End Sub Wanna Learn wrote: Hello This is my macro Range("K4").Select ActiveCell.FormulaR1C1 = _ "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE))" Range("K4").Select Selection.AutoFill Destination:=Range("K4:K7282") Range("K4:K7282").Select Columns("K:K").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K3").Select End Sub I get the results I want but ...This is a macro that I have to run everyday. So the auto fill range will be different every day . How do I correct the macro? thanks -- Dave Peterson |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
copy paste values macro
Your macro may be GREATLY simplified. What determines the last row to copy
to in col K. -- Don Guillett Microsoft MVP Excel SalesAid Software "Wanna Learn" wrote in message ... Hello This is my macro Range("K4").Select ActiveCell.FormulaR1C1 = _ "=IF(ISERROR(VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALS E)),"""",VLOOKUP(RC10,Sheet2!R1C1:R56C2,2,FALSE))" Range("K4").Select Selection.AutoFill Destination:=Range("K4:K7282") Range("K4:K7282").Select Columns("K:K").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K3").Select End Sub I get the results I want but ...This is a macro that I have to run everyday. So the auto fill range will be different every day . How do I correct the macro? thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for copy and paste values | Excel Discussion (Misc queries) | |||
Copy range in macro using paste special values | Excel Discussion (Misc queries) | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
Macro to open workbook and copy and paste values in to orig workbo | Excel Worksheet Functions | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) |