Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I'm trying to write a macro for formatting a .txt file into an Excel
spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Have you tried Selection.CurrentRegion.Select it's the VBA equivalent of Ctrl + Shift + * or Ctrl + (Num Pad) * -- Kevin Backmann "Corey" wrote: I'm trying to write a macro for formatting a .txt file into an Excel spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This seems to highlight cells above and below. I only want to either (1)
highlight everything below the current cell position or (2) highlight everything above the current cell position. Thanks. "Kevin B" wrote: Have you tried Selection.CurrentRegion.Select it's the VBA equivalent of Ctrl + Shift + * or Ctrl + (Num Pad) * -- Kevin Backmann "Corey" wrote: I'm trying to write a macro for formatting a .txt file into an Excel spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Corey:
Let's say you have selected any cell. Then Sub m2t() Dim i As Range Dim j As Range Set j = Cells(1, 1) Set i = Selection Range(i, j).EntireRow.Select End Sub Will select everything thru your selection to row #1. if you use Cells(65536,1) you will get the other sector. -- Gary''s Student "Corey" wrote: This seems to highlight cells above and below. I only want to either (1) highlight everything below the current cell position or (2) highlight everything above the current cell position. Thanks. "Kevin B" wrote: Have you tried Selection.CurrentRegion.Select it's the VBA equivalent of Ctrl + Shift + * or Ctrl + (Num Pad) * -- Kevin Backmann "Corey" wrote: I'm trying to write a macro for formatting a .txt file into an Excel spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Awesome Gary! Many thanks!!!
"Gary''s Student" wrote: Hi Corey: Let's say you have selected any cell. Then Sub m2t() Dim i As Range Dim j As Range Set j = Cells(1, 1) Set i = Selection Range(i, j).EntireRow.Select End Sub Will select everything thru your selection to row #1. if you use Cells(65536,1) you will get the other sector. -- Gary''s Student "Corey" wrote: This seems to highlight cells above and below. I only want to either (1) highlight everything below the current cell position or (2) highlight everything above the current cell position. Thanks. "Kevin B" wrote: Have you tried Selection.CurrentRegion.Select it's the VBA equivalent of Ctrl + Shift + * or Ctrl + (Num Pad) * -- Kevin Backmann "Corey" wrote: I'm trying to write a macro for formatting a .txt file into an Excel spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hmmm...I'm trying it now and I'm getting 'Ambiguous name detected: m2t' when
I try to run it ?? "Corey" wrote: Awesome Gary! Many thanks!!! "Gary''s Student" wrote: Hi Corey: Let's say you have selected any cell. Then Sub m2t() Dim i As Range Dim j As Range Set j = Cells(1, 1) Set i = Selection Range(i, j).EntireRow.Select End Sub Will select everything thru your selection to row #1. if you use Cells(65536,1) you will get the other sector. -- Gary''s Student "Corey" wrote: This seems to highlight cells above and below. I only want to either (1) highlight everything below the current cell position or (2) highlight everything above the current cell position. Thanks. "Kevin B" wrote: Have you tried Selection.CurrentRegion.Select it's the VBA equivalent of Ctrl + Shift + * or Ctrl + (Num Pad) * -- Kevin Backmann "Corey" wrote: I'm trying to write a macro for formatting a .txt file into an Excel spreadsheet. It's different everymonth. I can get all the keystrokes recorded correctly except for the following: Let's say a portion of the macro takes me to cell A1681, I would then like to highlight that row and all the rows above it (Ctrl+Shift+Home). However, it only references the count of rows between that and row 1, which will vary each time. Is there a code for this. Also, the opposite, if I'd rather highlight row A1681 and all the rows to the bottom of the spreadsheet. Any help is much appreciated. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Complicated If Then / V Lookup / Match Statement... | Excel Worksheet Functions | |||
Conform a total to a list of results? | Excel Discussion (Misc queries) | |||
Macro for changing text to Proper Case | Excel Worksheet Functions | |||
Find the cell value in excel by using vb code | Excel Discussion (Misc queries) | |||
close form code | Excel Discussion (Misc queries) |