Excel macro to format report
Solved/Closed
LaurenM
Posts
3
Registration date
Tuesday April 6, 2010
Status
Member
Last seen
April 6, 2010
-
Apr 6, 2010 at 06:16 PM
ramu sanga - Dec 29, 2014 at 02:08 AM
ramu sanga - Dec 29, 2014 at 02:08 AM
Related:
- Excel macro to format report
- Excel date format dd.mm.yyyy - Guide
- Marksheet format in excel - Guide
- Crystal report viewer download - Download - Data management
- Format factory - Download - Other
- Spell number in excel without macro - Guide
2 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 6, 2010 at 06:23 PM
Apr 6, 2010 at 06:23 PM
Why you need macro. How about using Transpose functionality when you do copy and then select pastespecial
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 7, 2010 at 09:20 AM
Apr 7, 2010 at 09:20 AM
Objective:
To splits lines is a cell and move each line to a new cell on the same row.
Assumptions
1. Data start at ROW 2
2. The data is in column A
3. Column next to A is where the data needs to be populated
4. Each line in the data cells should be moved to a new cell in the same row
Steps:
1. Read the assumptions
2. Make a backup of the file
3. Press ALT + F11 and insert a new module
4. Paste the code (after steps)
5. Execute the code
Code:
To splits lines is a cell and move each line to a new cell on the same row.
Assumptions
1. Data start at ROW 2
2. The data is in column A
3. Column next to A is where the data needs to be populated
4. Each line in the data cells should be moved to a new cell in the same row
Steps:
1. Read the assumptions
2. Make a backup of the file
3. Press ALT + F11 and insert a new module
4. Paste the code (after steps)
5. Execute the code
Code:
Sub SpiltData() Dim lMaxRows As Long Dim lRowBeanCounter As Long Dim vPos As Variant Dim sHold As String Dim sTemp As String Dim iCellCounter As Integer Dim lStartAtRow As Long lStartAtRow = 1 lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row For lRowBeanCounter = lStartAtRow To lMaxRows sTemp = Cells(lRowBeanCounter, "A") iCellCounter = 2 Do While sTemp <> "" vPos = 0 vPos = InStr(1, sTemp, Chr(10)) If vPos > 0 Then sHold = Left(sTemp, vPos - 1) sTemp = Trim(Mid(sTemp, vPos + 1)) Else sHold = sTemp sTemp = "" End If iCellCounter = iCellCounter + 1 Cells(lRowBeanCounter, iCellCounter) = sHold Loop Next lRowBeanCounter End Sub
Apr 6, 2010 at 06:26 PM
Address Suburb State Postcode Delivery Instructions Phone Number Fax Number Email Address
Very frustrating!
Apr 6, 2010 at 07:06 PM
Apr 6, 2010 at 07:18 PM
I have deleted all the information except for the first line due to privacy of customers and changed the information, but this will give you the idea of what the silly thing is doing!
Here is the link:
https://authentification.site/files/21815119/Xl00000001.xls
And here is the password I was given:
catazubajeji
Thanks so much for taking the time!
Apr 7, 2010 at 05:47 AM