custom strings

white_flag

Active Member
Joined
Mar 17, 2010
Messages
331
Hello I like to do somethnig like this via VBA:

so I like an code that will do this (create text in the following order):

AAbmk11, BBbmk11, CCbmk11 CCbmk12 CCbmk13 CCbmk14 CCbmk15 CCbmk16
AAbmk12, BBbmk12, CCbmk17 CCbmk18 CCbmk19 CCbmk20 CCbmk21 CCbmk22
AAbmk13, BBbmk13, CCbmk23 CCbmk24 CCbmk25 CCbmk26 CCbmk27 CCbmk28 etc

my not working logic is looking like this
Code:
    For i = 11 To 20
           Name:="AAbmk" & i
           Name:="BBbmk" & i
        For j = 1 To 16
           Name:="CCbmk" & i + j - 1
        Next
    Next
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
And what is "Name:="? Actually, it's a named parameter, but in your code there's no passing this parameter to Sub or Function.
 
Upvote 0
This will create the strings and insert them into the current worksheet.

Start off with a fresh worksheet before you run it.

Code:
Sub xxx()
    Dim s As String
    Application.ScreenUpdating = False
    k = 11
    For i = 11 To 20
           s = "AAbmk" & i & ", "
           s = s & "BBbmk" & i & ", "
        For j = 1 To 6
           s = s & "CCbmk" & k & ", "
           k = k + 1
        Next
        Cells(i - 10, 1) = Left(s, Len(s) - 2)
    Next
End Sub
 
Upvote 0
Weaver, thx

I like to apply this to word:

but I do not know how to define this or where to put the s-string:

Code:
        For j = 1 To 6
            With ActiveDocument.Bookmarks
                .Add Range:=Selection.Range, Name:="CCBmk" & k + 1
            End With
        Next
 
Upvote 0
Code:
        For j = 1 To 6
            With ActiveDocument.Bookmarks
                .Add Range:=Selection.Range, Name:="CCBmk" & k
                k = k + 1
            End With
        Next

so, Weaver one more time thx
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

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