Reputation: 77
I have a small suggestion as I am new to excel vba,
I like to update the some string in a particular cell(j,8) , where t is a string to be update ,t varies from 1 to 10 .
I like to update t value in "alt enter " in a specific cell
if the cell is already fill , I like to add new line
destlastrow = bsmWS.Range("A" & bsmWS.Rows.Count).End(xlUp).Row 'Checking the BSM/CMS/LDP/RCTA (Test Catalog)
For j = 2 To destlastrow
b = onlyDigits(bsmWS.Range("A" & j).value)
If InStr(b, "T") Or InStr(b, "") = 0 Then ' Check if it Test case or Test case ID
' do something
ElseIf InStr(b, "T") Or InStr(b, "D") Then
'do something
ElseIf InStr(b, "P") Or InStr(b, "D") Then
'do something
Else
iComp = StrComp(A, b, vbBinaryCompare)
Select Case iComp
Case 0
With tabWS
Inc value
erow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Range(.Cells(i, 2), .Cells(i, 3)).Copy .Range(.Cells(value, 8), .Cells(value, 9))
tabWS.Range("B" & i).Interior.ColorIndex = 4
End With 'tabWS
End Select
t = tabWS.Cells(value, 8).value
bsmWS.Cells(j, 8).value = t & vbCrLf
Exit For
End If
Next j
Above is my snippet. I want to update "t" value which I get it from another worksheet, want to update into another worksheet (j,8).
Can someone give a valuable suggestion , how to add new lines in (j,8)
More clarity:
If cell (5,8) has already a value cell (5,8) = "Already a string"
How can I add a new line in the same cell dim t as string t= "new line add"
How I can add t value in the next line to cell(5,8)
Upvotes: 0
Views: 9669
Reputation: 26
To get a new line you can use vbNewLine instead of vbCrLf.
To add to the text already in the cell use you can do it like this bsmWS.Cells(j, 8).value = bsmWS.Cells(j, 8).value & vbNewLine & t
Upvotes: 1