2016年8月10日星期三

How Can I Fix - Batch transpose macro?

Batch transpose macro

Please help, I am a newbie and struggling with this one.
Ive seen other answers close to this but they do not exactly answer.

Every month I import a data file into excel which is basically an online form which populates column A of the excel sheet.
It contains fieldc such as name, email, date, good experience etc.
I have approx 100 of these forms which I need to batch transpose
so the data appears transposed and runs from column B through to maybe AA (can happen on another tab if necessary).

This is how the format of the form looks, there is a break after each one so I showed 2 as an example;



Body

Date of experience : 06/13/2012

Ease of reservation : Excellent

Ease of reservation comments : Comments

Check in experience : Above average

Check in experience comments : Comments

Room number : 212

Cleanliness of bedroom : Above average

Cleanliness of bedroom comments : Comments

Standard of bedroom dicor : Below average

Standard of bedroom dicor comments : Comments

Cleanliness and condition of public areas : Above average

Cleanliness of public areas comments : Comments

Check out experience : Excellent

Check out experience comments : Comments

Ease of restaurant reservation : Please select

Ease of rest res comments : Comments

Welcome : Please select

Welcome comments : Comments

Breakfast experience : Please select

Breakfast Experience Comments : Comments

Lunch / dinner experience : Please select

Lunch/dinner experience comments  : Comments

Quality of food : Please select

Quality of food comments : Comments

Friendliness of team in restaurant : Please select

Friendliness of team in rest comments : Comments

Billing experience : Please select

Billing experience comments : Comments

In order to keep up to date with our special offers and news please enter your details below and we will send you our regular newsletter : True

E mail address :





-----

No virus found in this message.

Checked by AVG - www.avg.com

Version: 2012.0.2180 / Virus Database: 2437/5105 - Release Date: 07/01/12


Date of experience : 06/27/2012

Ease of reservation : Above average

Ease of reservation comments : Comments

Check in experience : Above average

Check in experience comments : Comments

Room number : 302

Cleanliness of bedroom : Excellent

Cleanliness of bedroom comments : Comments

Standard of bedroom dicor : Above average

Standard of bedroom dicor comments : Comments

Cleanliness and condition of public areas : Above average

Cleanliness of public areas comments : Comments

Check out experience : Above average

Check out experience comments : Comments

Ease of restaurant reservation : Above average

Ease of rest res comments : Comments

Welcome : Above average

Welcome comments : Comments

Breakfast experience : Not applicable

Breakfast Experience Comments : Comments

Lunch / dinner experience : Above average

Lunch/dinner experience comments  : Comments

Quality of food : Above average

Quality of food comments : Comments

Friendliness of team in restaurant : Excellent

Friendliness of team in rest comments : Comments

Billing experience : Above average

Billing experience comments : Comments

E mail address : 



I would like the Macro to select all of the data in column A and transpose it across rows so it looks something like this;

Ease of Reservation Ease of reservation comments Check in experience etc
Ease of Reservation Ease of reservation comments Check in experience etc
Ease of Reservation Ease of reservation comments Check in experience etc
Ease of Reservation Ease of reservation comments Check in experience etc

That way I can then search and replace the comments to change them into values to average the data.

I keep getting stuck on the Macro/VB code, please help I would be very grateful! Thank you so much Charly

This

Anwsers to the Problem Batch transpose macro

Download SmartPCFixer for Free Now

In that case, why did it stop after only 3 blocks?  I think I might have an idea.
Change this line in the code:
    While Range("C" & lnFirstRow).Value <> ""
to this:
    While Range("B" & lnFirstRow).Value <> ""
Now the code will check if the first cell in the block in column B is empty to determine when to finish working down column C.
If I'm right, in your fourth block, there was no "Date of experience" entered???
If that doesn't work, then yes, I need to see more of your data to work out what is happening.
Cheers
Rich

Hi Rich,
 
Hope you don't mind,I played around with your code.
Originally it was getting the calculation for lnGap wrong so when calculating the start/end row for subsequent blocks of data it was one row out each time and this was cumulative.
This now works for me.
 
Sub TransposeBlocks()
     Dim i As Long, lnFirstRow As Long, lnLastRow As Long, lnGap As Long, lnLen As Long
 
    Columns("A:A").Replace What:=" : ", Replacement:=":", _
         LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
         SearchFormat:=False, ReplaceFormat:=False
    
    Columns("A:A").TextToColumns _
         Destination:=Range("B1"), _
         DataType:=xlDelimited, _
         TextQualifier:=xlDoubleQuote, _
         ConsecutiveDelimiter:=False, _
         Tab:=False, _
         Semicolon:=False, _
         Comma:=False, _
         Space:=False, _
         Other:=True, _
         OtherChar:=":", _
         FieldInfo:=Array(Array(1, 1), Array(2, 1)), _
         TrailingMinusNumbers:=True
    
    Columns("D:E").ClearContents
    
    For i = 1 To 100
         If Trim(Cells(i, "B").Value) = "Date of experience" Then
             lnFirstRow = i
         ElseIf Trim(Cells(i, "B").Value) = "E mail address" Then
             lnLastRow = i
             Exit For
         End If
     Next i
     For i = lnLastRow + 1 To lnLastRow + 100
         If Trim(Cells(i, "B").Value) = "Date of experience" Then
            lnGap = (i - lnLastRow) - 1
             'lnGap = i - lnLastRow
             Exit For
         End If
     Next i
     If lnFirstRow = 0 Or lnLastRow = 0 Or lnGap = 0 Then Stop
     lnLen = (lnLastRow - lnFirstRow) + 1
    
    Range(Range("B" & lnFirstRow), Range("B" & lnLastRow)).Copy
     Range("D1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
         SkipBlanks:=False, Transpose:=True
     Application.CutCopyMode = False
    
    i = 2 'destination row
    
    While Range("C" & lnFirstRow).Value <> ""
         Range(Range("C" & lnFirstRow), Range("C" & lnLastRow)).Copy
         Range("D" & i).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
             SkipBlanks:=False, Transpose:=True
    
        lnFirstRow = (lnLastRow + lnGap) + 1
         lnLastRow = (lnFirstRow + lnLen) - 1
         i = i + 1
     Wend
    
    Columns("B:C").Delete Shift:=xlToLeft
     Range("B1").Select
 End Sub

Make Sure that your Hardware Meets the System Requirements

Microsoft Windows Requirements :

  • 1 gigahertz (GHz) or faster 32-bit (x86) or 64-bit (x64) processor
  • 1 gigabyte (GB) RAM (32-bit) or 2 GB RAM (64-bit)
  • 16 GB available hard disk space (32-bit) or 20 GB (64-bit)

This error can be due to some configuration requirements for you system. If your computer hardware is not up to par, then make sure you update where necessary before continuing.

Another Safe way to Repair the Problem: Batch transpose macro:

How to Fix Batch transpose macro with SmartPCFixer?

1. Click the button to download Error Fixer . Install it on your computer.  Open it, and it will perform a scan for your computer. The errors will be shown in the scan result.

2. After the scan is finished, you can see the errors and problems need to be repaired. Click Fix All.

3. When the Fixing part is finished, your computer has been speeded up and the errors have been fixed


Related: Autologon and AutoLogonCount Parameters for Windows Unattended Setup Error Fixer,How To Resolve Cyberbit Unicode Font Does Not Return Correct Charset Problem,How To Use the Office Profile Wizard to Create an OPS File in Office XP Error Fixer,Error Sys Msg 22 Invalid period, please reenter. in MC in 4.x Solution,Why am I Getting a Upgrades from 3.01 to 3.60 or 3.01 to 3.70 Involving Serial Numbers and Revaluations Are Overstating the Valuation Entries on the Purchases Error?,How Can I Fix - Error 16389?,How to Fix - Internetopen?,Mcafee Virus Scan Online,How Can I Fix - Qos Packet Scheduler Failed?,Solution to Problem: Windows 2000 Boot Repair,How to Fix ashoutxt.dll Not Found Error,Best Method to Fix cxcore096.dll Error,Where can I Find dsauth.dll File,msde.dll Corrupted - How to Resolve,psizewizres.dll Corrupted - How to Fix,How to Download ASUS XGI Compatible Super VGA Driver Package Version R1.13.00/Driver Version 6.14.10.1130 for Windows XP 32/64 bit(WHQL),Windows Server 2003 32/64 bit(WHQL),Windows Vista 32/64 bit(WHQL),Windows Server 2008 32/64 bit(WHQL),Windows 7 32/64 bit(WHQL),Window,Download NeoMagic® MagicMedia 256AVP Display Adapter Driver,Download NVIDIA RIVA TNT2 Model 64,How to Update Realtek ALC850 AC'97 Driver V5.10.0.5900 WHQL for Windows 2000/XP/2003 & 64bit XP/2003.,How to Update Realtek LAN V6.203.0214.2008,Microsoft.PowerShell.GraphicalHost.dll Error Code Fixer
,Fix Error Code Netapi32 (4).dll
,Qa_auth_client.dll Error Code Fixer
,Fix Error Code Tdc (3).ocx
,Vwipxspx.dll Error Code Fixer
,Way to Download Toshiba Qosmio X505-Q832 Intel Wireless LAN Driver v.12.4.1.11.0.s64_wCAT,Download Toshiba Satellite C650D-ST6N02 Assist Utility v.4.2.3.0 driver,How Can You Update & Download Toshiba Satellite L645-S4026RD Value Added Package v.1.6.0130.640202 driver,Method to Download Toshiba Satellite L755-S9511D Assist Utility v.4.2.3.1 driver,Method to Download Toshiba Satellite P875-S7200 Fingerprint Utility v.2.0.0001.000408 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17
Read More: How to Resolve - Black Screen (With Cursor) - Windows 8.1?,Troubleshooting:Black Screen Acer Extensa 5235 Error,Troubleshoot:black screen after logging into the windows 8.1 Error,How to Resolve - Banking online will not save my ID's?,How to Fix Problem - Bitlocker Error when extending partitions in Windows 7 Professional?

没有评论:

发表评论

注意:只有此博客的成员才能发布评论。