Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Macro to format data.

I have a report that needs to be imported into excel from a text file and
formatted daily. I would like to automate the formatting process with a
macro, unfortunately, my VBA skills are not very good.

Could one of you please help me with the macro?

I think what I need it to do should be fairly simple.

If the cell in column e is blank then I want cells a, b, c, and d
(respectively) to all move one cell to the right. This should be be applied
to the entire set of data (usually about 350 rows)

Thats it.

Thanks in advance,
DIane
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro to format data.

Sub ProcessAllLines()
Dim LastRow As Long
Dim i As Long

With Activesheet

LastRow = .Cells(.Rows.Count,"A").End(xlUp).Row
For i = 1 To LastRow

If .Cells(i, "E").Value = "" Then

.Cells(i, "A").Resize(,4).Cut .Cells(i, "B")
End If
Next i
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"diaare" wrote in message
...
I have a report that needs to be imported into excel from a text file and
formatted daily. I would like to automate the formatting process with a
macro, unfortunately, my VBA skills are not very good.

Could one of you please help me with the macro?

I think what I need it to do should be fairly simple.

If the cell in column e is blank then I want cells a, b, c, and d
(respectively) to all move one cell to the right. This should be be
applied
to the entire set of data (usually about 350 rows)

Thats it.

Thanks in advance,
DIane



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to format data.

Start a new workbook

Start recording a macro that will be stored in this macro workbook.

File|Open your text file that needs to be imported. Format it the way you
like. Insert columns, add headers, freeze panes, widen columns, add filters, do
the page setup--everything you can think of.

When you're done, save that workbook with the macro.

I like to put a big button from the Forms toolbar on the only worksheet in that
macro workbook and assign this macro to that big button. I'll add a few
instructions to that sheet, too.

If the file name to open is always the same and in the same location, then I'm
about done. If the location or file name changes, I'll tweak the code to ask
for the file.

My tweaked code could look a little like:

Option Explicit
Sub Testme01()

Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.OpenText Filename:=myFileName '....rest of recorded code here!

End Sub

diaare wrote:

I have a report that needs to be imported into excel from a text file and
formatted daily. I would like to automate the formatting process with a
macro, unfortunately, my VBA skills are not very good.

Could one of you please help me with the macro?

I think what I need it to do should be fairly simple.

If the cell in column e is blank then I want cells a, b, c, and d
(respectively) to all move one cell to the right. This should be be applied
to the entire set of data (usually about 350 rows)

Thats it.

Thanks in advance,
DIane


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro to format data.

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("E" & RowCount) = "" Then
Range("A" & RowCount).Insert Shift:=xlToRight
End If
RowCount = RowCount + 1
Loop

"diaare" wrote:

I have a report that needs to be imported into excel from a text file and
formatted daily. I would like to automate the formatting process with a
macro, unfortunately, my VBA skills are not very good.

Could one of you please help me with the macro?

I think what I need it to do should be fairly simple.

If the cell in column e is blank then I want cells a, b, c, and d
(respectively) to all move one cell to the right. This should be be applied
to the entire set of data (usually about 350 rows)

Thats it.

Thanks in advance,
DIane

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Macro to format data.

Perfect!

Thanks all of you for your help. Eventually I am going to get around to
learning VBA for myself...thank goodness you all are out here to help until
then.

Diane

"Joel" wrote:

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("E" & RowCount) = "" Then
Range("A" & RowCount).Insert Shift:=xlToRight
End If
RowCount = RowCount + 1
Loop

"diaare" wrote:

I have a report that needs to be imported into excel from a text file and
formatted daily. I would like to automate the formatting process with a
macro, unfortunately, my VBA skills are not very good.

Could one of you please help me with the macro?

I think what I need it to do should be fairly simple.

If the cell in column e is blank then I want cells a, b, c, and d
(respectively) to all move one cell to the right. This should be be applied
to the entire set of data (usually about 350 rows)

Thats it.

Thanks in advance,
DIane



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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
Macro to Change Changing Date Format Data to Text Rod Bowyer Excel Discussion (Misc queries) 3 October 11th 07 12:02 PM
format in macro brian thompson3001 via OfficeKB.com Excel Discussion (Misc queries) 1 December 20th 06 11:57 AM
Macro to Saved Selected Excel data to .CSV format joelbeveridge Excel Discussion (Misc queries) 18 August 8th 06 12:59 PM
format macro Jonathan Cooper Excel Discussion (Misc queries) 5 January 9th 06 08:49 PM


All times are GMT +1. The time now is 04:25 PM.

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

About Us

"It's about Microsoft Excel"