Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to move text from one field to another

I have a report that is exported to Excel using Crystal Reports. There are
about 18,000 entries. The report puts the Item Category in the row above each
section of items. I need it to go in the same row, only in the column in
front of it. In other words, there may be 30 different types of screws, but
they are all under the SCREWS category. The report puts SCREWS the section as
a title. I need it to go in the column beside the description of the screw.
There are over 500 different categories. Any help is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Macro to move text from one field to another

Hi Wayne,
I had to make a few assumptions:
1. The "Item Category" is in the first column, i.e. A1, A50, etc.
2. The cell to the immediate right of the "Item Category" (B1, B50, etc.) is
empty.
3. Except for the "Item Category" rows, all the other rows have data in
column B.

Given those assumptions, this macro may do what you want. It will put the
"Item Category" in front of each row and will delete the rows that have the
"Item Category" in the header.

Option Explicit
Dim ILoop As Integer
Dim NumRows As Integer
Dim Title As String
Sub AddTitles()

'Turn off warnings, etc.
Application.ScreenUpdating = False
Application.DisplayAlerts = False
NumRows = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
Columns("A").Insert

For ILoop = 1 To NumRows
If IsEmpty(Cells(ILoop, "C")) Then
Title = Cells(ILoop, "B")
End If
Cells(ILoop, "A") = Title
Next ILoop

For ILoop = NumRows To 1 Step -1
If IsEmpty(Cells(ILoop, "C")) Then
Rows(ILoop).Delete
End If
Next ILoop

'Turn on warnings, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Use Alt+F11 to open the Visual Basic Editor.
Go to Insert Module and paste this code into it.
Be sure to back up your data before trying the macro.

--
Ken Hudson


"Wayne via OfficeKB.com" wrote:

I have a report that is exported to Excel using Crystal Reports. There are
about 18,000 entries. The report puts the Item Category in the row above each
section of items. I need it to go in the same row, only in the column in
front of it. In other words, there may be 30 different types of screws, but
they are all under the SCREWS category. The report puts SCREWS the section as
a title. I need it to go in the column beside the description of the screw.
There are over 500 different categories. Any help is appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does my tab move to the end of the visable field instead of 1 Anne Excel Worksheet Functions 2 September 1st 07 10:09 PM
insert data into macro code from text input field? john_t_h[_15_] Excel Programming 1 January 16th 04 03:14 AM
HELP!! Populate text in single XL field, or bulk copy text into 1 field filmfatale[_2_] Excel Programming 0 December 9th 03 02:30 PM
VBA Creating a Macro to Move some of the text from one cell to another Lowell B. Copeland Excel Programming 4 August 28th 03 08:15 PM
VBA Creating a Macro to Move some of the text from one cell to another Ron de Bruin Excel Programming 0 August 28th 03 07:21 PM


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"