Running Macros In diffirenet sheet.

Fsailoh

New Member
Joined
Jan 14, 2019
Messages
16
Hi, I am running a MACRO in sheet2 by clicking on a bottom on sheet1, all of my code is working very well, except here:

.Columns("H2:I20000").SpecialCells(xlCellTypeBlanks).Select
.Selection.FormulaR1C1 = "=R[-1]C"

What i am trying to do here is to tell excel to go to Find & Select > Go To Special > Select Blanks, and then apply certain for all of the Blanks Cells which is "=R[-1]C".

thanks.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
.Range("H2:I20000").SpecialCells(xlCellTypeBlanks).Select
 
Upvote 0
same problem, now it tells me:

"compile error:
Method or data member not found"

and it highlight ".Selection".
 
Upvote 0
Code:
Sub Test()

Dim ws As Worksheet
Set ws = Sheets("Sheet2")
With ws
    .Columns("A:E").Copy
    .Range("H1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
               
    .Range("$H$1:$L$1048354").AutoFilter Field:=1, Criteria1:="="
    .Range("H2:H20000").ClearContents
    .Range("$H$1:$L$1048354").AutoFilter Field:=1
           
    .Range("$H$1:$L$1048354").AutoFilter Field:=2, Criteria1:="="
    .Range("I2:I20000").ClearContents
    .Range("$H$1:$L$1048354").AutoFilter Field:=2
             
    .Range("$H$1:$L$1048354").AutoFilter Field:=3, Criteria1:="="
    .Range("J2:J20000").ClearContents
    .Range("$H$1:$L$1048354").AutoFilter Field:=3
    
   
   .Range("$H$1:$L$1048354").AutoFilter Field:=3, Criteria1:="="
    .Range("K2:L20000").ClearContents
    .Range("$H$1:$L$1048354").AutoFilter Field:=3
    
    .Range("H1:I1").ClearContents
    .Range("H1").FormulaR1C1 = " "
    .Range("I1").FormulaR1C1 = " "
     
  [COLOR=#FF0000]   .Columns("H2:I20000").SpecialCells(xlCellTypeBlanks).Select
    .Selection.FormulaR1C1 = "=R[-1]C"
    [/COLOR]
    .Columns("H:L").Copy
    .Columns("H:L").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    
    
    .Range("H1").FormulaR1C1 = "Group"
    .Range("I1").FormulaR1C1 = "GL"
    

    End With
End Sub
 
Last edited by a moderator:
Upvote 0
When posting code please use code tags, the # icon in the reply window.

Try
Code:
On Error Resume Next
.Range("H2:I20000").SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
On Error GoTo 0
 
Upvote 0
In place of the two lines in red from post#5
 
Upvote 0
YESSSSSSSSSSSSSS now it works very well! thanks Fluff, could you give me an idea about what does this code mean?
 
Upvote 0
You're welcome & thanks for the feedback.
The code simply puts the formula in all blank cells in the your range
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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