![]() |
need urgent help on macro merging
The following macro merges correctly entries which jhave more than one row
,,, but when only one entry per name is available then it merges along with it the next row also. can any1 pls tell me where i have to correct Dim e As Integer e = 1000 Dim i1 As Integer Dim st As Integer i1 = 3 st = 3 Dim name As String Dim sr As Integer Dim ps As Long name = Cells(i1, 2).value sr = Cells(i1, 1).value ps = Cells(i1, 3).value For i1 = 3 To e If (name < Range("B" & i1)) And (sr < Range("A" & i1)) And (ps < Range("C" & i1)) Then Range("B" & st & ":B" & i1 - 1).merge Range("A" & st & ":A" & i1 - 1).merge Range("C" & st & ":C" & i1 - 1).merge name = Cells(i1 + 1, 2).value sr = Cells(i1 + 1, 1).value ps = Cells(i1 + 1, 3).value st = i1 ElseIf (name = Range("B" & i1) And i1 < 3) Then Range("A" & i1) = "" Range("B" & i1) = "" Range("C" & i1) = "" End If Next i1 |
need urgent help on macro merging
hi
use these 4 fomulas formula assumes the wrapped text is in D8. adjust to suit. =LEFT(D8,77) gets first line =MID(D8,79,74) gets second line =MID(D8,153,71) gets third line =RIGHT(D8,26) gets last line regards FSt1 "deepika :excel help" wrote: The following macro merges correctly entries which jhave more than one row ,,, but when only one entry per name is available then it merges along with it the next row also. can any1 pls tell me where i have to correct Dim e As Integer e = 1000 Dim i1 As Integer Dim st As Integer i1 = 3 st = 3 Dim name As String Dim sr As Integer Dim ps As Long name = Cells(i1, 2).value sr = Cells(i1, 1).value ps = Cells(i1, 3).value For i1 = 3 To e If (name < Range("B" & i1)) And (sr < Range("A" & i1)) And (ps < Range("C" & i1)) Then Range("B" & st & ":B" & i1 - 1).merge Range("A" & st & ":A" & i1 - 1).merge Range("C" & st & ":C" & i1 - 1).merge name = Cells(i1 + 1, 2).value sr = Cells(i1 + 1, 1).value ps = Cells(i1 + 1, 3).value st = i1 ElseIf (name = Range("B" & i1) And i1 < 3) Then Range("A" & i1) = "" Range("B" & i1) = "" Range("C" & i1) = "" End If Next i1 |
need urgent help on macro merging
but how do i say that within a macro... and i m actually merging rows of A,B
and C cols which are dynamic "FSt1" wrote: hi use these 4 fomulas formula assumes the wrapped text is in D8. adjust to suit. =LEFT(D8,77) gets first line =MID(D8,79,74) gets second line =MID(D8,153,71) gets third line =RIGHT(D8,26) gets last line regards FSt1 "deepika :excel help" wrote: The following macro merges correctly entries which jhave more than one row ,,, but when only one entry per name is available then it merges along with it the next row also. can any1 pls tell me where i have to correct Dim e As Integer e = 1000 Dim i1 As Integer Dim st As Integer i1 = 3 st = 3 Dim name As String Dim sr As Integer Dim ps As Long name = Cells(i1, 2).value sr = Cells(i1, 1).value ps = Cells(i1, 3).value For i1 = 3 To e If (name < Range("B" & i1)) And (sr < Range("A" & i1)) And (ps < Range("C" & i1)) Then Range("B" & st & ":B" & i1 - 1).merge Range("A" & st & ":A" & i1 - 1).merge Range("C" & st & ":C" & i1 - 1).merge name = Cells(i1 + 1, 2).value sr = Cells(i1 + 1, 1).value ps = Cells(i1 + 1, 3).value st = i1 ElseIf (name = Range("B" & i1) And i1 < 3) Then Range("A" & i1) = "" Range("B" & i1) = "" Range("C" & i1) = "" End If Next i1 |
need urgent help on macro merging
but how do i say that within a macro,, my columns A,B,C are dynamic
"FSt1" wrote: hi use these 4 fomulas formula assumes the wrapped text is in D8. adjust to suit. =LEFT(D8,77) gets first line =MID(D8,79,74) gets second line =MID(D8,153,71) gets third line =RIGHT(D8,26) gets last line regards FSt1 "deepika :excel help" wrote: The following macro merges correctly entries which jhave more than one row ,,, but when only one entry per name is available then it merges along with it the next row also. can any1 pls tell me where i have to correct Dim e As Integer e = 1000 Dim i1 As Integer Dim st As Integer i1 = 3 st = 3 Dim name As String Dim sr As Integer Dim ps As Long name = Cells(i1, 2).value sr = Cells(i1, 1).value ps = Cells(i1, 3).value For i1 = 3 To e If (name < Range("B" & i1)) And (sr < Range("A" & i1)) And (ps < Range("C" & i1)) Then Range("B" & st & ":B" & i1 - 1).merge Range("A" & st & ":A" & i1 - 1).merge Range("C" & st & ":C" & i1 - 1).merge name = Cells(i1 + 1, 2).value sr = Cells(i1 + 1, 1).value ps = Cells(i1 + 1, 3).value st = i1 ElseIf (name = Range("B" & i1) And i1 < 3) Then Range("A" & i1) = "" Range("B" & i1) = "" Range("C" & i1) = "" End If Next i1 |
All times are GMT +1. The time now is 08:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com