Thread: [Solved] Concatenate Macro VBA
View Single Post
 
Old 09-21-2018, 07:27 AM
rsrasc rsrasc is offline Windows 10 Office 2013
Competent Performer
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Quote:
Originally Posted by Pecoflyer View Post
You don't really need a macro for this Just group the sheets ( while holding down the Shift key select the first and the last sheet tab)
Enter the formula in the first sheet
Automatically all other sheets will have the formula in the same position
Record a macro to automate the process if required

I agree that I don't need a macro to accomplish this.

Seems to be really easy.

My intention is to be able to do it with a macro. That way I would like to be able to automate what I'm trying to do. The main purpose is that I can combine it with other macros and run it automatically.


I have tried the below code but does not work so I'm getting a Run-time error "1004". Application-define or object-defined error.

If someone can help me with this, I will appreciate it.


Will keep trying...


Code:
Sub Main()
  Dim ws As Worksheet, c As Long, s$
  For Each ws In Worksheets
    With ws
      c = .Cells(.Rows.Count, "B").End(xlUp).Row
      s = "=NF" & "-" & "A1" & Left(B10, 5) & "-" & Mid(B10, 7, 45) & "--Budget 2019"
      'Debug.Print s
      .Range("A10").Formula = s
      .Range("A10").Copy .Range(.Range("A10"), .Cells(c, "A"))
    End With
  Next ws
End Sub

Thanks all.
Reply With Quote