0

I'm trying to create a dynamic workbook where I have two Workbooks: one that contains my VB code, and a second containing the Sheets.

As they drop down regions it will update the value depending on the Regions, then update the rest of the Cells.

Sub Retrieve_Sales()
    Dim OldRegin As String  // Range [support_NP_E10_T12_CP1a_T12-Regions.xlsx]Region 1'!$B$2 
    Dim NewRegion As String // drop down with Regions 1 - Regions 20

    OldRegion = Range("F2").Select
    NewRegion = Range("C4").Select

    Application.StatusBar = "Retrieing data on" & NewRegion
    Application.ScreenUpdating = False

    Range("F2").Replace(OldRegion, NewRegion)
End Sub

I keep receiving Expected =. Am I suppose to wrap it to a variable?

user513951
  • 12,445
  • 7
  • 65
  • 82
Hugo
  • 659
  • 2
  • 7
  • 18

1 Answers1

3

You might have several issues.

First, for the Expected = message change the .Replace line to:

Range("F2").Replace OldRegion, NewRegion

For more details, see the answer here: https://stackoverflow.com/a/15519085/2258

Also, I expected you want the .Value of the Range, not the .Select

OldRegion = Range("F2").Value
NewRegion = Range("C4").Value
Community
  • 1
  • 1
Richard Morgan
  • 7,601
  • 9
  • 49
  • 86
  • Almost, you corrected some of my mistake. Now im going to make a small change i noticed to Range should be E3:F19. As i made the change [support_NP_E10_T12_CP1a_T12-Regions.xlsx]Region 1'!$B$2 region is not updating to what variable i'm updating to. – Hugo May 15 '14 at 22:02
  • Thank you i found out my problem..., missed misspelled the variables. – Hugo May 15 '14 at 22:58