method or data member not found

tamtadada

New Member
Joined
Mar 20, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a piece of code which works with defined specific sheet name (of course it does not do exactly what I need but it`s correct from syntax point of view) but when I try to define the sheet name where I need to paste the range selected as variable "i" I get a compile error - it`s the line in red.
any idea how to fix it please?
VBA Code:
Dim LR As Integer, i As Integer
    Application.ScreenUpdating = False
    With Sheets("DED")
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        For i = 1 To LR
            Sheets("Template").Copy After:=Sheets("Template")
            ActiveSheet.Name = .Range("A" & i).Value
            Range("B4").Value = .Range("A" & i).Value
            
            Sheets("pivot").Select
            Columns("A:A").Select
            Selection.Find(What:=.i, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
            
            ActiveCell.Offset(1, 0).Select
            Dim AC As Range
            Dim LC As Range
            Set AC = ActiveCell
            Do Until ActiveCell.Offset(1, 0) = blank
                ActiveCell.Offset(1, 0).Select
            Loop
            Set LC = ActiveCell.Offset(0, 5)
            [COLOR=rgb(226, 80, 65)]Range(AC, LC).Copy Destination:=Worksheets.i.Range("B9")[/COLOR]
    Next i
    End With
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
VBA Code:
Worksheets.i.Range("B9")

Your worksheet reference is invalid. Maybe this:
VBA Code:
Worksheets(i).Range("B9")
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
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