Excel VBA Set Activecell Formula With String

majesteleri

New Member
Joined
Aug 18, 2023
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi everybody,

I'm trying to write a code. I want to insert a formula into the cell, but I get an error "Runtime error 1004"

I tried everything but couldnt find where the problem is.

error row is : ActiveCell.Formula = "=SUMPRODUCT(" & strRange1 & ")"

Pls help me.

VBA Code:
Sub KOFormulDuzenle()
'
' KOFormulDuzenle Makro
'

'
  Application.ScreenUpdating = False
  Dim TLTOPLAMLAR As Integer
  Dim TCFormul As String
  Dim strRange1 as String
  ActiveWorkbook.Sheets("Keşif Özeti").Select

    firmasayisi = Range("A1").Value
        Cells.Find(What:="Sıra" & Chr(10) & "No", After:=ActiveCell, LookIn:=xlFormulas2, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    
    kesifilksatir = ActiveCell.Row + 1
    
    Cells.Find(What:="TL TOPLAMLAR", After:=ActiveCell, LookIn:=xlFormulas2, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    TLTOPLAMLAR = ActiveCell.Row
    Range("A5").Select
        Cells.Find(What:="Kur", After:=ActiveCell, LookIn:=xlFormulas2, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    Kur = ActiveCell.Column
    
        Cells.Find(What:="Miktar", After:=ActiveCell, LookIn:=xlFormulas2, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    Miktarsutun = ActiveCell.Column
    
    kesifsatirsayisi = kesifsonsatir - kesifilksatir
    
For i = 0 To 4
Range("A5").Select
    Cells.Find(What:="Malzeme" & Chr(10) & "Birim Fiyatı", After:=ActiveCell, LookIn:=xlFormulas2, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
MBF = ActiveCell.Column

strRange1 = Chr(64 + Miktarsutun) & kesifilksatir & ":" & Chr(64 + Miktarsutun) & TLTOPLAMLAR - 1 & ";" & Chr(64 + Kur) & kesifilksatir & ":" & Chr(64 + Kur) & TLTOPLAMLAR - 1 & ";" & Chr(64 + MBF + i) & kesifilksatir & ":" & Chr(64 + MBF + i) & TLTOPLAMLAR - 1
strRange2 = Chr(64 + MBF + i) & TLTOPLAMLAR
TCFormul = "=SUMPRODUCT(" & strRange1 & ")"
Range(strRange2).Select
ActiveCell.Formula = "=SUMPRODUCT(" & strRange1 & ")"


Next i
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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