Extract normal font to new cell [closed] - excel

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have multiple cells with bold font and normal font, I am looking to only extract the font that isn't bold to a new cell. Does anyone know how I can do this?
Thanks

You can just do the reverse of what Siddarth was doing in the post I linked - for example:
Using this:
Sub Test()
Dim mystring As String
For i = 1 To Len(Range("A1").Value)
If Range("A1").Characters(i, 1).Font.FontStyle = "Regular" Then
mystring = mystring & Mid(Range("A1").Value, i, 1)
ElseIf Len(mystring) > 0 Then
Debug.Print Trim(mystring)
mystring = ""
End If
If i = Len(Range("A1").Value) Then
Debug.Print Trim(mystring)
End If
Next i
End Sub
Returns:

Related

How Might I Extract Specific Characters From A String Using VBA [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Question: Consider the following string, s, which is equal to:
\\xxxxxx.com\xxx\xxx\xxx\xxx\xxx\xxx\xxx\04. xxx\02. xxx\B. xxxx\yyy
What code might be used in order for PlaceHolderIndex to have the value "04.02.B" ?
Below is a small VBA function that accepts a string, splits it using "\" as a separator, ignores the first part ("\xxxxxxx.com\"), then looks for "." in each of the sections, and concatenates the data before the ".".
Function fGetData(strInput As String) As String
Dim aData() As String
Dim lngLoop1 As Long
aData = Split(strInput, "\")
For lngLoop1 = 3 To UBound(aData) ' ignore the first 3 elements as they are "\\xxxxx.com\"
If InStr(aData(lngLoop1), ".") > 0 Then
fGetData = fGetData & Left(aData(lngLoop1), InStr(aData(lngLoop1), "."))
End If
Next lngLoop1
If Right(fGetData, 1) = "." Then fGetData = Left(fGetData, Len(fGetData) - 1)
End Function
Regards,

Excel Display Zeros in Number Without Error [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
In excel VBA how do I display the following numbers as they appear without generating the 'Number stored as text' error in the cell?
1.0
1.1
1.2
.
.
1.99
1.100
1.101
1.102
.
.
1.20
1.21
1.22
.
.
etc...
Just keep track of the number of decimal places that need to be displayed. For example:
Sub marine()
Dim s As String, i As Long, a
s = "1.0,1.1,1.2,1.99,1.100,1.101,1.102,1.20,1.21,1.22"
arr = Split(s, ",")
i = 1
For Each a In arr
With Cells(i, 1)
.Value = a
brr = Split(a, ".")
.NumberFormat = "0." & Application.Rept("0", Len(brr(1)))
End With
i = i + 1
Next a
End Sub
This is based on the curious fact that if VBA puts a number-like string into a cell, Excel will convert it into a number:
Sub demo()
Dim s As String
s = "1.230"
Range("A1").Value = s
End Sub
EDIT#1:
On the other hand, if you want to enter text that look like numbers, but avoid raising the error flag, then:
Sub Macro1()
Application.ErrorCheckingOptions.NumberAsText = False
End Sub

Auto fill macro [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a task to create a loop that fills in columns with the following data:
Column A should populate with a number from 1 to 10000,
Column B should populate with a today's date and increment with the number,
Column C should populate with number of a day of the week so repeating from 1 to 7 every week,
Column D should populate with a day of the week from Monday to Sunday (text).
I think this could be achieved with a For ...Next loop. More complicated would be with the dates...
Could you please give me a hint how to go about this?
THank you
try this
Sub mm()
Dim i As Long
Dim weekDayNames As Variant
With Range("A1:A10000")
.Formula = "=ROW()"
.Offset(, 1).FormulaR1C1 = "=Today()+RC1-1"
.Offset(, 2).FormulaR1C1 = "=WEEKDAY(RC2,1)"
With .Offset(, 1).Resize(, 2)
.Value = .Value
End With
weekDayNames = Application.Transpose(.Offset(, 2).Value)
For i = 1 To UBound(weekDayNames)
weekDayNames(i) = WeekdayName(weekDayNames(i), False, vbSunday)
Next
.Offset(, 3).Value = Application.Transpose(weekDayNames)
End With
End Sub

Excel VBA to multiply cell if another cell contains text [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I do know the formula but not sure how to translate into VBA.
Need a VBA script to do the following.
If cell D contains Debit, then value in F multiply -1
If cell D contains Credit, then value in F multiply 1
Loop until last row.
Use this macro:
Sub subMultiply()
For Each cel In Range("D1:D" & Range("D1").End(xlDown).Row)
If cel.Value = "Debit" Then
cel.Offset(0, 2).Value = Val(cel.Offset(0, 2)) * (-1)
ElseIf cel.Value = "Credit" Then
cel.Offset(0, 2).Value = Val(cel.Offset(0, 2)) * 1
End If
Next
End Sub

creating a macro to separate data [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
HI I am new to using excel and only have a basic knowledge in designing macros. I want to be able to design a macro that can separate different invoice details depending on the company unique id into a separate sheet. only problem there is two or three rows that need to be moved together. How would I go about doing this?
For example:
Here is a sample picture of the data. what i want to do is copy the H and N in rows 1 and 2 deepening on the value in row D
Assuming your testing for something like 'is value > 25'
Sub Macro1()
Dim dat As Variant
Dim rng As Range
Dim i As Long
Dim cntr As Integer
cntr = 1
Set rng = [A1:A5]
dat = rng ' dat is now array (1 to 5, 1 to 1)
For i = LBound(dat, 1) To UBound(dat, 1)
If rng(i, 1).Offset(0, 3).Value > 25 Then
Sheets("Sheet2").Range("A" & cntr).Value = Range("A" & i).Value
cntr = cntr + 1
End If
Next
End Sub

Resources