Click here to Skip to main content
15,890,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Continuous data string to Access using vb 2010. Pin
Eddy Vluggen29-Apr-16 2:13
professionalEddy Vluggen29-Apr-16 2:13 
GeneralRe: Continuous data string to Access using vb 2010. Pin
Dave Kreskowiak29-Apr-16 2:54
mveDave Kreskowiak29-Apr-16 2:54 
PraiseRe: Continuous data string to Access using vb 2010. Pin
Gus11312-May-16 0:08
Gus11312-May-16 0:08 
Questionloop through VBA Pin
Rohit Lal25-Apr-16 23:29
Rohit Lal25-Apr-16 23:29 
AnswerRe: loop through VBA Pin
Richard MacCutchan25-Apr-16 23:43
mveRichard MacCutchan25-Apr-16 23:43 
GeneralRe: loop through VBA Pin
Rohit Lal26-Apr-16 0:53
Rohit Lal26-Apr-16 0:53 
GeneralRe: loop through VBA Pin
Richard MacCutchan26-Apr-16 1:52
mveRichard MacCutchan26-Apr-16 1:52 
AnswerRe: loop through VBA Pin
Sonhospa26-Apr-16 2:21
Sonhospa26-Apr-16 2:21 
Nobody knows what you exactly want to do, so it's always needed that you understand - at least to a certain extent - the code and methods someone gives you. It would make a lot of sense to read the hints Richard gave you, instead of trying to make him do your homework.

You can loop through your worksheets - assuming here that the shop worksheets are all named something with "Shop" - like this:
VB
Sub LoopWorksheets()
    Dim ws As worksheet
    
    For Each ws In ActiveWorkbook.Worksheets
        ' filter only the shops worksheets
        If UCase(ws.Name) Like UCase("Shop*") Then
            ' do something
            RADIUS ws
        End If
    Next
    ' put stuff like that (e.g. cleaning) after the work...
    Application.Calculation = xlCalculationAutomatic
End Sub

The UCASE is needed, because the function is case sensitive (looking for "Shop" would not match your sheet "SHOP")! I would also recommend you to rename your method, because "radius" is a math function and might lead to confusion.

Your function would then consume every worksheet that your loop passes:
VB
Sub RADIUS(ByVal sheet As worksheet)

You can also streamline your function a lot. Instead of
VB
Worksheets("WAREHOUSE").Activate
Range("C2:d2").Select
Selection.Copy
sheet.Activate
Range("f2:g4175").PasteSpecial Operation:=xlPasteSpecialOperationAdd

you could just use one line:
VB
sheet.Range("f2:g4175").Value = Worksheets("WAREHOUSE").Range("C2:d2").Value
There's no need to activate every worksheet before doing something on/with it. This is only needed in certain cases, e.g. if you explicitly want to "Select" an object (sheet, range, cell etc.). Usually you just reference the range like "sheet.range(...)". For example
VB
ActiveWorkbook.Worksheets("WAREHOUSE").Range("A1:H1").Interior.ColorIndex = 3
will paint your WAREHOUSE sheet titles red.

Regards
Mick

modified 26-Apr-16 10:31am.

QuestionHow to sort already filtered gridview data? The data is sorted but the sorting sort the whole data instead in the range that was set by the filter. Thanks in advance. Pin
Member 1247499425-Apr-16 21:15
Member 1247499425-Apr-16 21:15 
SuggestionRe: How to sort already filtered gridview data? The data is sorted but the sorting sort the whole data instead in the range that was set by the filter. Thanks in advance. Pin
Richard MacCutchan25-Apr-16 21:47
mveRichard MacCutchan25-Apr-16 21:47 
QuestionWhat does "GetFiles" do in system directories? Pin
Sonhospa25-Apr-16 1:14
Sonhospa25-Apr-16 1:14 
AnswerRe: What does "GetFiles" do in system directories? Pin
Richard Deeming25-Apr-16 2:01
mveRichard Deeming25-Apr-16 2:01 
GeneralRe: What does "GetFiles" do in system directories? Pin
Sonhospa25-Apr-16 2:46
Sonhospa25-Apr-16 2:46 
AnswerRe: What does "GetFiles" do in system directories? Pin
Bernhard Hiller25-Apr-16 22:12
Bernhard Hiller25-Apr-16 22:12 
GeneralRe: What does "GetFiles" do in system directories? Pin
Sonhospa26-Apr-16 3:23
Sonhospa26-Apr-16 3:23 
AnswerRe: What does "GetFiles" do in system directories? Pin
Sonhospa26-Apr-16 4:16
Sonhospa26-Apr-16 4:16 
QuestionUpdate UI of MDI Parent Pin
Sonhospa25-Apr-16 0:49
Sonhospa25-Apr-16 0:49 
QuestionVBScript DeleteFolder method cannot delete folders under System32 on Win 8.1 Pin
robwm121-Apr-16 10:36
robwm121-Apr-16 10:36 
AnswerRe: VBScript DeleteFolder method cannot delete folders under System32 on Win 8.1 Pin
Dave Kreskowiak21-Apr-16 14:31
mveDave Kreskowiak21-Apr-16 14:31 
AnswerRe: VBScript DeleteFolder method cannot delete folders under System32 on Win 8.1 Pin
Sonhospa25-Apr-16 0:59
Sonhospa25-Apr-16 0:59 
QuestionHow can i make the official VB.net TCP async Example work ?! Pin
Ghassan Mohamed Yousif20-Apr-16 23:53
Ghassan Mohamed Yousif20-Apr-16 23:53 
AnswerRe: How can i make the official VB.net TCP async Example work ?! Pin
Dave Kreskowiak21-Apr-16 2:09
mveDave Kreskowiak21-Apr-16 2:09 
GeneralRe: How can i make the official VB.net TCP async Example work ?! Pin
Ghassan Mohamed Yousif22-Apr-16 9:45
Ghassan Mohamed Yousif22-Apr-16 9:45 
GeneralRe: How can i make the official VB.net TCP async Example work ?! Pin
Dave Kreskowiak22-Apr-16 15:57
mveDave Kreskowiak22-Apr-16 15:57 
QuestionConversion from string "" to type 'Integer' is not valid Pin
kishore-201620-Apr-16 1:46
kishore-201620-Apr-16 1:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.